实时单击和名为"name"的输入的jQuery问题 [英] jQuery issue with live click and input named "name"
本文介绍了实时单击和名为"name"的输入的jQuery问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果表单包含名为"name"的输入,则jQuery实时单击对我不起作用.将名称更改为其他名称会有帮助.谁能告诉我为什么会这样吗?
jQuery live click isn't working form me if form contains input named "name". Changing name to something else helps. Can anyone tell me why that happens?
当我单击名为值"的输入时,如果有一个名为命名"实时单击的字段不起作用.如果我将名称从名称"更改为名称2",则单击名为值"的字段即可.
If there is a field name "named" live click is not working when I click input named "value". If I change name from "name" to "name2" clicking on field named "value" works.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script>
$('form[name="prepare"] input[name="value"]').live('click', function(){
alert('Clicked!');
return false;
});
</script>
<form name="prepare" method="post">
<input type="text" name="name" />
<input type="text" name="value" />
</form>
推荐答案
如果用id
而不是name
解决<form>
,则错误消失:
if you address your <form>
by id
instead of by name
the bug disappears:
<form name="prepare" method="post" id="myform">
$('form#myform input[id="value"]').click(function(){
这篇关于实时单击和名为"name"的输入的jQuery问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文