![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery :checked Selector
The :checked selector in jQuery is used to look for all the checked radio button or checkboxes and selects them.
Syntax
The syntax is as follows −
$(":checked")
Example
Let us now implement the :checked selector in jQuery −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> </head> <body> <h2>Favourite Subject</h2> <form> <div> Maths: <input type="radio" name="sub" value="Maths"> </div> <div> English <input type="radio" name="sub" value="English"> </div><br> <div id="content"></div> </form> <script> $( "input" ).on( "click", function() { $( "#content" ).html( $( "input:checked" ).val() + " is the favourite subject" ); }); </script> </body> </html>
Output
This will produce the following output −
Select “Maths” radio button above −
Now, select “English” radio button −
Advertisements