Site icon G-Net Consulting | Web Development

Use JQuery to see if a checkbox is checked

There are times with JQuery that you may need to see if a checkbox is checked or not, and based on that value, do certain things. This little snippet has come in handy a lot for a project I’ve been working on lately. Simply do the following:

if ($(“#fieldname”).is(‘:checked’) == true) {
return true;
} else {
return false;
}

That’s pretty much it! Has worked well in all of the recent browsers I’ve tried it in.

Exit mobile version