我在这里遇到问题。首先对标识码:选择标签点击,jQuery不“注意”
<input type="radio" name="user_by_list" value="" id="userbylist"/>
<div id="userbylist1">
<select>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
<input type="radio" name="user_by_text" value="" id="userbytext"/>
<div id="userbytext1">
<input type="text" value=""/>
</div>
这是我的jQuery代码:
$("#userbylist").click(function() {
$("#userbytext").prop('checked', false); // for unchecking the opposite radiobutton
});
$("#userbytext").click(function() {
$("#userbylist").prop('checked', false); // for unchecking the opposite radiobutton
});
$("#userbylist1").click(function() { // for clicking the whole div
$("#userbylist").prop('checked', true); // checking #userbylist radiobutton
$("#userbytext").prop('checked', false); // unchecking #userbytext radiobutton
});
$("#userbytext1").click(function() { // for clicking the whole div
$("#userbytext").prop('checked', true); // checking #userbytext radiobutton
$("#userbylist").prop('checked', false); // unchecking #userbylist radiobutton
});
现在的问题是,当我在选择标签点击获取div的单选按钮来检查,这不是不起作用,但是当我点击文本输入区域时,它工作正常。当你点击整个div时,它会根据什么函数进行检查和取消选中,以便工作正常。我已经尝试为所有选项设置类,并且还在整个<select>
标记上设置了一个ID。这里有帮助吗?
PS。如果你不明白,虽然我试图尽我所能解释问题,但我已经设置了an example page
这对我的作品在Firefox和Chrome上。你有什么浏览器遇到问题? –
你使用IE吗?在哪种模式下? –
我使用Chrome也很奇怪。 – finst33