我有一个名为保存更改功能,它看起来像这样Java脚本按钮vs链接提交?
function saveChanges() {
var theCity = city.value;
var theState = state.value;
var theEmail = email.value;
var theAge = age.value;
var theGender = gender.value;
var theOther = other.value;
alert("theCity is: "+ theCity);
alert("theState is: "+ theState);
alert("theEmail is: "+ theEmail);
alert("theAge is: "+ theAge);
alert("theGender is: "+ theGender);
alert("theOther is: "+ theOther);
}
window.onload=function(){
document.getElementById('ok').onclick=saveChanges;
}
,我有就可以了简单的HTML页面的多个输入。
要提交内容,我在底部有一个链接。
<a href="#" id="ok" style="color:white;">Click here <-- </a>
我做了一个按钮,具有相同的id ='ok',它不起作用。
我错过了什么?
你错过的 “不工作” 正确的描述。怎么了?控制台中是否有错误?按钮的代码是什么? – Amadan
当然这不起作用,'id'在文档中应该是唯一的。 – nhahtdh
你也错过了你的按钮的代码。 – gideon