Javascript代码是
function addConformationNo(){
var confirmationNo = document.getElementById("addedconfirmation").val();
alert(confirmationNo);
}
Run Code Online (Sandbox Code Playgroud)
我addConformationNo()在点击一个按钮时调用函数
当addConformationNo()函数被执行时,函数调用document.getElementById每次都返回null。为什么?有什么线索吗?
任何一个:
DOM元素没有val与它们相关的方法,那么你很可能得到一个“属性未定义或不是一个函数”的错误,但抱怨val没有返回值getElementById。
value改为访问该属性。
var confirmationNo = document.getElementById("addedconfirmation").value;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2632 次 |
| 最近记录: |