87,993
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
</head>
<body>
<form name="form1" action="#">
<input type="text" value=""/>
<input type="button" onclick="form1.reset();alert('ok');" value="reset"/>
</form>
</body>
</html>
<form id="form1">
<input value="def" id="test" name="test" />
<input type="reset" id="btnReset" value="Reset" />
</form>
<script type="text/javascript">
//<![CDATA[
var i=0;
function foo(){
alert(i++);
}
$(function(){
$('#btnReset').unbind('click').bind('click',function(event){
//阻止默认事件
event.preventDefault();
foo();
$('form#form1')[0].reset();
foo();
});
});
//]]>
</script>