Javascript 当用户选择某个复选框时,取消选中所有文本框
这是我的密码。我想要的是,当我选中一个复选框时,另一个复选框将取消选中。。。像单选按钮一样的行为。。但是使用td类。。。在jquery中可能吗Javascript 当用户选择某个复选框时,取消选中所有文本框,javascript,jquery,html,Javascript,Jquery,Html,这是我的密码。我想要的是,当我选中一个复选框时,另一个复选框将取消选中。。。像单选按钮一样的行为。。但是使用td类。。。在jquery中可能吗 <table> <tr> <td class="example"> <input type="checkbox" /> </td> <td class="example"> <
<table>
<tr>
<td class="example">
<input type="checkbox" />
</td>
<td class="example">
<input type="checkbox" />
</td>
<td class="example">
<input type="checkbox" />
</td>
<td class="example">
<input type="checkbox" />
</td>
</tr>
</table>
提前感谢。您可以使用:
$(":checkbox").change(function(){
$(this).closest('tr').find('input').not(this).prop('checked', false);
});
您可以使用:
$(":checkbox").change(function(){
$(this).closest('tr').find('input').not(this).prop('checked', false);
});
抱歉给你们添麻烦了。。。我已经拿到了 这是密码
$('.example input').on('click', function() {
$('.example input').not(this).prop('checked', false);
});
抱歉给你们添麻烦了。。。我已经拿到了 这是密码
$('.example input').on('click', function() {
$('.example input').not(this).prop('checked', false);
});
试试这个:
$('table').on('click', ':checkbox', function() {
// On click of any checkbox inside the table
// If checkbox is checked then only uncheck others
if ($(this).is(':checked')) {
$('table').find(':checkbox').not(this).prop('checked', false);
}
});
演示:试试这个:
$('table').on('click', ':checkbox', function() {
// On click of any checkbox inside the table
// If checkbox is checked then only uncheck others
if ($(this).is(':checked')) {
$('table').find(':checkbox').not(this).prop('checked', false);
}
});
演示:试试看
$('.example').click(function() {
$('.example').find('input[type=checkbox]').prop('checked', false);
$(this).find('input[type=checkbox]').prop('checked', true);
});
试试看
$('.example').click(function() {
$('.example').find('input[type=checkbox]').prop('checked', false);
$(this).find('input[type=checkbox]').prop('checked', true);
});
就是这样:)
$(“输入[type='checkbox'])。在(“更改”,函数()上){
$(“input[type='checkbox']”)prop(“checked”,false);
$(this).prop(“选中”,true);
});代码>
就是这样:)
$(“输入[type='checkbox'])。在(“更改”,函数()上){
$(“input[type='checkbox']”)prop(“checked”,false);
$(this).prop(“选中”,true);
});代码>
使用下面的代码。工作
使用下面的代码。工作
显示您尝试过的jquery/javascript代码??为什么不为此使用无线电输入?CMS和模型设计问题。。。实体模型的设计看起来像是别无选择。。。我使用的cms在单选按钮方面有点困难。@user3113490你单选按钮
如果你想要单选按钮,比如你尝试过的行为显示jquery/javascript代码??为什么你不使用单选输入?cms和模型设计问题。。。实体模型的设计看起来像是别无选择。。。我使用的cms在单选按钮方面有点困难。@user3113490你单选按钮如果你想要单选按钮一样的行为,你需要检查复选框是否选中,你需要检查复选框是否选中,如果($(this).is(':checked'),这一行是不必要的{
Optimization,当单击同一复选框时,如果($(this).is(':checked')){
Optimization,当单击同一复选框时,不需要此行