Jquery 选择输入复选框并将样式添加到其父项
我正在选中一个复选框并将样式添加到其父标记中。它工作得很好。我不知道的是,当它已经被选中并删除样式时,如何做相反的操作 HTML 很明显,我使用alert只是为了在单击时检查它是否处于选择状态。您可以尝试此操作(使用Jquery 选择输入复选框并将样式添加到其父项,jquery,html,css,Jquery,Html,Css,我正在选中一个复选框并将样式添加到其父标记中。它工作得很好。我不知道的是,当它已经被选中并删除样式时,如何做相反的操作 HTML 很明显,我使用alert只是为了在单击时检查它是否处于选择状态。您可以尝试此操作(使用更改事件): 您可以尝试以下操作(使用changeevent): 您可以尝试以下操作(使用changeevent): 您可以尝试以下操作(使用changeevent): 单击后,您可以使用检查复选框是否已选中: $("input:checkbox").click(function(
更改
事件):
您可以尝试以下操作(使用change
event):
您可以尝试以下操作(使用change
event):
您可以尝试以下操作(使用change
event):
单击后,您可以使用检查复选框是否已选中:
$("input:checkbox").click(function() {
if(!$(this).prop("checked"))
alert();
else
$(this).parent().parent().css("background-color","yellow");
});
单击后,您可以使用检查复选框是否已选中:
$("input:checkbox").click(function() {
if(!$(this).prop("checked"))
alert();
else
$(this).parent().parent().css("background-color","yellow");
});
单击后,您可以使用检查复选框是否已选中:
$("input:checkbox").click(function() {
if(!$(this).prop("checked"))
alert();
else
$(this).parent().parent().css("background-color","yellow");
});
单击后,您可以使用检查复选框是否已选中:
$("input:checkbox").click(function() {
if(!$(this).prop("checked"))
alert();
else
$(this).parent().parent().css("background-color","yellow");
});
您可以使用以下选项:
$("input:checkbox").click(function() {
var isChecked = $(this).attr('checked')?true:false;
if(isChecked){
$(this).parent().parent().css("background-color","yellow");
}
else
$(this).parent().parent().css("background-color","");
});
您可以使用以下选项:
$("input:checkbox").click(function() {
var isChecked = $(this).attr('checked')?true:false;
if(isChecked){
$(this).parent().parent().css("background-color","yellow");
}
else
$(this).parent().parent().css("background-color","");
});
您可以使用以下选项:
$("input:checkbox").click(function() {
var isChecked = $(this).attr('checked')?true:false;
if(isChecked){
$(this).parent().parent().css("background-color","yellow");
}
else
$(this).parent().parent().css("background-color","");
});
您可以使用以下选项:
$("input:checkbox").click(function() {
var isChecked = $(this).attr('checked')?true:false;
if(isChecked){
$(this).parent().parent().css("background-color","yellow");
}
else
$(this).parent().parent().css("background-color","");
});