我有以下的HTMLAddClass使用jQuery目标需要帮助
<fieldset>
<legend>
<input type="checkbox" class="myCheck">Click
</legend>
content
<fieldset>
我想选中该复选框时添加类和删除选中的时候。应该像这样的工作:
$(".myCheck").change(function() {
if ($(this).is(':checked')){
$(this).parent("fieldset").addClass("myClass");
} else {
$(this).parent("fieldset").removeClass("myClass");
}
});
我错过了什么?