Both javaScript and JQuery, have problems in redefining some attributes directly in form.
Such as type='text', we could not remodify the type. So does the attribute onclick.
Method one:(Isolated button onclick event):
var button = document.getElementById("yourbuttonId");
button.onclick = function(){alert('aaaaaaaa');};
Note: this method could used in any web browser
(注:此方法适用于任何浏览器。不存在兼容问题。推荐~~)
Method two:(the submit event in form)
var form = document.getElementById("yourformId");
form.onsubmit = function(){alert('aaaaa');};
form.action = "javascript:void(0)";
Note: javascript:void(0) makes the form do noting in action
2009年11月16日星期一
订阅:
博文评论 (Atom)
没有评论:
发表评论