
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Use jQuery to get values of selected checkboxes?
Yes, we can use jQuery to get values of selected checkboxes using the concept of input. We have to also use the :checked selector.
Example
Following is the code −
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <body> <input type="checkbox" name="checkDemo" id="check1" value="Cricket" /> <label for="check1">Cricket</label> <input type="checkbox" name="checkDemo" id="check2" value="Listening Music" /> <label for="check2">Listening Music</label> <input type="checkbox" name="checkDemo" id="check3" value="Reading NewsPaper" /> <label for="check3">Reading NewsPaper</label> <br> <button type="button">Click Me</button> <script> $(document).ready(function () { $("button").click(function () { $('input[name="checkDemo"]:checked').each(function () { console.log(this.value); }); }); }); </script> </html>
To run the above program, save the file name anyName.html(index.html) and right click on the file. Select the option “Open with live server” in VS Code editor.
This will produce the following output −
Now, select the checkbox −
This will produce the following output on console −
- Related Articles
- Display selected checkboxes on another page using JavaScript?
- How to make checkboxes impossible to check in jQuery?
- How to use Checkboxes in ReactJS?
- jQuery :selected Selector
- Multi-selection of Checkboxes on button click in jQuery?
- Unselecting multiple Checkboxes on button click in jQuery?
- How to get selected text from a drop-down list (select box) using jQuery?
- How can I get the selected value of a drop-down list with jQuery?
- How to use jQuery to get the value of HTML attribute of elements?
- How to get and set form element values with jQuery?
- How to get value of data attribute and use it in jQuery?
- How to find all siblings of currently selected object in jQuery?
- How to use GET method to send data in jQuery Ajax?
- How to use attr() method in jQuery to get the value of an attribute?
- How to get the total number of checkboxes in a page using Selenium?

Advertisements