<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
<title>函數接受參數并彈出</title>
<style>
body{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?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="changanqu"?/>
</p>
<p><button>傳參</button></p>
</body>
</html>求解答!??!謝謝
6 回答

GavinZeng
TA貢獻31條經驗 獲得超20個贊
var?myFn?=?function(a,b){ ????alert(a,value);?//?a,value?改成?a.value ????alert(b,value)??//?b,value?改成?b.value };
錯一個地方,可以說是不小心,錯兩個地方,說明對語法掌握的不熟練。
假如你是真的不小心的話,那就要學會使用控制臺檢查Bug
- 6 回答
- 0 關注
- 1826 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消