This code works fine with jQuery 1.5.1, but when I use jQuery 1.6.0 it changes the value of the checkbox after click, but it does not add the class ‘done’ to the element.
$("input:checkbox").live('change', function(eve) {
eve.preventDefault();
var el = this.id ;
var done = this.done ;
if( $(this).attr("checked") == true ) {
$('#item-'+el).find(".text").addClass('done');
//return false;
}
if( $(this).attr("checked") == false ) {
$('#item-'+el).find(".text").removeClass('done');
//return false;
}
$.post('taskDone.php', {
id: this.id,
value: $(this).attr("checked") ? 1 : 0
}, function(data) {});
});
prior to 1.6
$(this).attr("checked")is inconsistent, as it can be a boolean or it can be a stringjQuery says something like: attribute is what’s inside a property. so, it stopped sending you a
boolvalue and it’s sending you astringvalue instead.if you change all
to
you will have no problems
from jQuery Documentation