mrkeck Sharing the Love

13Apr/141

jQuery attr vs prop for Checkbox

attr is iffy

$('.checkbox').attr('checked', true);      //Doesn't work
$('.checkbox').attr('checked', 'checked'); //Sometimes works
$('.checkbox').attr('checked', false);     //Works

but prop works every time

$('.checkbox').prop('checked', true);  //Works
$('.checkbox').prop('checked', false); //Works
Filed under: HTML, jquery Leave a comment
Comments (1) Trackbacks (0)
  1. Hі, just wanted tо tell you, I liked this post. It was helpful.
    Keep on posting!


Leave a comment

No trackbacks yet.