.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> JQuery >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Check if Checkbox is checked or not using jQuery

Posted By:JQuery Developer       Posted Date: May 20, 2013    Points: 40    Category: JQuery    URL: http://www.dotnetspark.com  

This JQuery code example is to check or determine if Checkbox is checked or not using jQuery in a web form.
 

Sometime you want to know that in your web form is checked or not using JQuery. Below is the simple JQuery code to solve this problem.

Lets create a html check box with id myCheckBox and set the checked attribute to checked

<input type="checkbox" checked="checked" id="myCheckBox" name="number" value=" " />

 

JQuery code to check Checkbox status

$("#myCheckBox").is(":checked")

Now to test this code I have created a function isCheckBoxChecked and called it from a html button in below example

function isCheckBoxChecked() {
    alert($("#myCheckBox").is(":checked")); ;
}

HTML code for HTML button

<input type="button" name="name" onclick="javascript:isCheckBoxChecked()" value=" Click Me " />

and the alert box message is true

similarly you can check for radio button too weather radio button is check or not.

 


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend