jQuery 事件的问题
为什么以下代码点击按钮第一次没反应,点击第二次才弹出一个框,点第三次弹二个,第四次弹三个,第五次弹4个....修改测试了一天,也没搞明白是怎么回事
程序代码:<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>1</title>
<script src="js/jquery.js" type="text/javascript"></script>
<body>
<form id="form2" onsubmit="return ok();">
<input name="nane" type="text" id="name" />
<input type="submit" name="button" value="提交" id="button1" />
</form>
</body>
</html>
<script>
function ok()
{
$("#button1").click(function(){
if ($("#name").val() == "1"){alert("yy");}
//if ($("#name").val() != "1"){alert("nn")};
});
return false;
}
</script>






