0

How do I see if a checkbox is ticked in jQuery ?

I tried the following code:

$(#cbx).attr('checked')

but this did not work correctly

  • It might have worked if you had used `.prop` `$("#cbx").prop('checked')` - in basic terms (it's never this simple) `.attr` gives you the HTML attributes (what was in the string when it was sent from the server) while `.prop` gives you the DOM properties (the variables that change as things happen). It's *not* that simple, but this will get you a long way. – freedomn-m Feb 09 '23 at 13:22

0 Answers0