我遇到了一个简单表单的问题,我试图在某人键入内容时触发ajax请求。调试完成后,当事件被解除时,我会留下警报,但它会显示两次,而与浏览器无关。 (忽略输入标签中的'rel'属性,除非你认为它的rel属性导致问题)。jquery事件无端触发两次
<form class="formBig" name="formRegister" id="formRegister" method="post" action="">
<label class="label" id="locationLabel" for="location">Location</label>
<input class="input" name="location" id="location" type="text" rel="locationLabel" value="" />
</form>
<script type="text/javascript">
$("#location").click(function() {
alert($(this).attr('id'));
});
</script>
什么是您的jQuery版本?你能发布你的整个HTML和JS代码吗? – Crozin 2010-03-11 07:25:58
这段代码没问题。这是另一回事,你有没有两次包括JavaScript文件? – Anurag 2010-03-11 07:31:04