这个并不难,就不做解释了。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#div1{
width:250px;height:50px;
padding-left:40%;
}
#div1 input{
width:200px;height:20px;
margin:10px;
}
#div1 button{
margin-left:90px;
}
</style>
</head>
<body>
<div id="div1">
<input type="text" value="北京市" id="input1"><br/>
<input type="text" value="朝阳区" id="input2"><br/>
<button id="button1">传参</button>
</div>
<script>
document.getElementById("button1").οnclick=function()
{
var a=document.getElementById("div1").getElementsByTagName("input");
for(var i=0;i<a.length;i++)
{
var s=a[i].value;
alert(s);
}
}
</script>
</body>
</html>