jQuery checkbox checked state changed event

Bind to the change event instead of click. However, you will probably still need to check whether or not the checkbox is checked:
Example below shows and hide a div when checkbox checked or unchecked

$("#your_checkbox").change(function() {
    if(this.checked) {
        $("#div").show();
    }
    else{
        $("#div").hide();
    }
});

By Keenlio, July 25, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 8 = fourteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>