I always see it done like

$('#test1').is(":checked")

As for "correct" or "better", that would be totally personal
preference

Matthew Neilson wrote:
> Hello everyone,
>
> I was wondering what the "proper" way to check if a checkbox is checked is
> using jquery?
>
> I've run into two methods... both of which appear to work fine in
> IE,FF,Chrome and safari.
>
> http://jsbin.com/ifoka/edit
>
> Assuming that I have two checkboxes, one with an id of test1 and one with an
> id of test2, i used these two methods:
>
> $('#test1').is(":checked")
> $('#test2').attr("checked")
>
>
> Which method is better? Or is there a different way which is even more
> correct?
>
> Thanks,
>
> Matt

Reply via email to