checkbox is not checked – jQuery


How do you know when a form checkbox is not checked?

is(:checked)

We’ll use the jQuery selectors like this:
<script>
function my_function(){

   if(! $('#my_checkbox').is(':checked')){
                
    alert("Please check it!");

  }else{

      // submit the form
      $('#my_form').submit(); 

  }

}
</script>
checkbox is not checked – jQuery checkbox is not checked – jQuery Reviewed by JohnBlogger on 5:15 PM Rating: 5

No comments: