原生javascript学习:函数接受参数并弹出
01 <!DOCTYPE html>
02 <html>
03 <head>
04
05 <style>
06 body {font: 12px/1.5 Tahoma; text-align:center;}
07 input,button {font-family:inherit}
08 input{border:1px solid #ccc; padding:3px}
09 button{cursor:pointer}
10 </style>
11
12 <script>
13 var myFn = function(a, b) {
14 alert(a.value);
15 alert(b.value);
16 }
17
18 window.onload = function() {
19 var oInput = document.getElementsByTagName("input");
20 var oBtn = document.getElementsByTagName("button")[0];
21 oBtn.onclick = function() {
22 myFn(oInput[0],oInput[1]);
23 }
24 };
25 </script>
26
27 </head>
28 <body>
29 <p><input type="text" value="北京市" /></p>
30 <p><input type="text" value="朝阳区" /></p>
31 <p><button>传参</button></p>
32 </body>
33 </html>
作者:黎宇浩
补充:web前端 , JavaScript ,