javascript - Element has `checked` attributes but isn't checked? -
i using threedubmedia's drag , drop selection feature check , uncheck couple checkboxes. check , uncheck them once, no more that. what's more, when @ elements using inspect, start without checked attribute, should; gain when selected, should; , lose when selected again, should. however, gets strange. if select third time, gains checked attribute, not check! , if select fourth time, nothing happens! have no idea what's causing this.
currently, removing attribute (using removeattr()) instead of turning off (e.g. prop('checked', false)).
you should using prop(). following works:
if (this.checked) { $(this).prop('checked', false); } else { $(this).prop('checked',true); } or better yet, @pointy mentioned:
.drop(function( ev, dd ){ this.checked = !this.checked; });
Comments
Post a Comment