Saturday, 17 August 2019 08:24

how to see if checkbox checked using jquery

Written by 
Rate this item
(0 votes)

It's a common task that you need to check if your single checkbox 

is checked or not before doing something with that.

 There are many solutions throughout the web but i am showing a 

cool one works well. suppose you have html codes like the following

<form> 

<input type="checkbox" name="mrcf-privacy" class="mrcf-input-boxes" id="mrcf-privacy" value="no"/>  Tick to confirm you have read and agree with the <a href="/" style="text-decoration:underline; color:navy;">Privacy notice</a><br/>        

<input type="submit" id="mrcf-submitted" name="mrcf-submitted" class="mrcf-input-boxes" value="Send"></form>

now the following jquery codes verifies if checkbox is checked. 

jQuery(function(){        

       if(jQuery('#mrcf-privacy').is(':checked')){  jQuery('#mrcf-submitted').submit();  }

}); 

Isn't that pretty simple? hope you liked it, don't forget to share and connect with me.

 

Read 1457 times Last modified on Saturday, 17 August 2019 08:30
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.