jquery checked checkbox IE problem

Posted by lidermin on Stack Overflow See other posts from Stack Overflow or by lidermin
Published on 2010-03-26T17:27:59Z Indexed on 2010/03/26 18:03 UTC
Read the original article Hit count: 337

Filed under:

Hi, I'm having an issue verifying if a checkbox is checked using jquery on Internet Explorer. This is the code I'm using:

if ($('#chkjq_1').attr('checked') == true)

It works fine on Firefox or Chrome, but on Internet Explorer 7, the condition is always false because the browser sets the property this way:

<input id="chkjq_1" type="checkbox" CHECKED/> IE7

And the right way is the following: (Firefox, Chrome):

<input id="chkjq_1" type="checkbox" checked="checked"/> FF, Chrome, etc

What should I do to avoid this issue on Internet Explorer 7; is there a generic way in jquery to solve this?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about jQuery