我有以下的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");
}
});
我錯過了什麼?