How do I check whether a checkbox is checked in jQuery?

JavascriptWeb DevelopmentObject Oriented Programming

To check whether a checkbox is checked in jQuery, use the concept of toggle(). Following is the code −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<link rel="stylesheet" href="//">
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="">
<input type="checkbox" id="selectName"/>
<div id="txtName" style="display:none">Your name is Adam Smith</div>
   $('#selectName').click(function() {

To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VS Code editor.


This will produce the following output −

When you select the check box, the following will be the output −

Published on 14-Sep-2020 10:03:12