<!DOCTYPE html><html><head> <meta charset="utf-8" /> <title>函數接收參數并彈出</title> <style type="text/css"> body {font: 12px/1.5 Tahoma; text-align: center;} input {border: 1px solid #ccc; padding: 3px;} button {cursor: pointer;} </style> <script type="text/javascript"> var myFn = function(a,b) { alert(a.value); alert(b.value) }; window.onload = function() { var oInput = document.getElementsByTagName("input"); var oBtn = document.getElementsByTagName("button")[0]; oBtn.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>能一次性alert出框中內容?
JS 函數接收參數并彈出
翻翻過去那場雪
2018-11-15 14:18:25