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.

http://i.snag.gy/aieog.jpg

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); } 

jsfiddle here.


or better yet, @pointy mentioned:

.drop(function( ev, dd ){   this.checked = !this.checked; }); 

jsfiddle here.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -