prop()
methodYou 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">
<head>
<meta charset="utf-8">
<title>jQuery Check/Uncheck Checkbox</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$(".check").click(function(){
$("#myCheck").prop("checked", true);
});
$(".uncheck").click(function(){
$("#myCheck").prop("checked", false);
});
});
</script>
</head>
<body>
<p><input type="checkbox" id="myCheck"> Are you sure?</p>
<button type="button" class="check">Yes</button>
<button type="button" class="uncheck">No</button>
</body>
</html>
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 harsukh21@gmail.com
How to get the position of an element relative to the document using jQuery
Use the jQuery offset() method...Laravel Passport - Create REST API with authentication
Today, in this tutorial we are share wit...How to Create REST API in Laravel7 using JWT
Hello Artisan In this tutorial...Failed to clear cache. Make sure you have the appropriate permissions in Laravel
Hi, Hello Laravel artisan. this is...HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
in this article, I will share with you h...