标签:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>函数接收参数并弹出</title>
<style>
body{font:12px/1.5 Tahoma;text-align:center;}
code,input,button{font-family:inherit;}
input{border:1px solid #ccc;padding:3px;}
button{cursor:pointer;}
</style>
<script>
var myFn = function(a,b){
alert(a.value);
alert(b.value);
};
window.onload = function(){
var oInput = document.getElementsByTagName("input");
var oButton = document.getElementsByTagName("button")[0];
oButton.onclick = function(){
myFn(oInput[0],oInput[1]);
}
};
</script>
</head>
<body>
<p><input type="text" value="北京市"/></p>
<p><input type="text" value="丰台区"/></p>
<p><button>传参</button></p>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/zhaoyixin/p/4512339.html