How to check or uncheck a checkbox dynamically using jQuery

  1652 views   2 years ago jQuery

Use the jQuery prop() method

You can use the jQuery prop() method to check or uncheck a checkbox dynamically such as on click of button or an hyperlink etc. The prop() method require jQuery 1.6 and above.

Let's try out the following example to understand how it basically works:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Check/Uncheck Checkbox</title>
<script src=""></script>
        $("#myCheck").prop("checked", true);
        $("#myCheck").prop("checked", false);
    <p><input type="checkbox" id="myCheck"> Are you sure?</p>
    <button type="button" class="check">Yes</button>
    <button type="button" class="uncheck">No</button>  


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]