prop()
methodYou can use the jQuery prop()
method to check or uncheck radio button dynamically such as on click of button or an hyperlink etc. The prop()
method require jQuery 1.6 and above.
Let's check out the following example to understand how it basically works:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Check/Uncheck Radio Button</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$(".check-male").click(function(){
$("#male").prop("checked", true);
});
$(".check-female").click(function(){
$("#female").prop("checked", true);
});
});
</script>
</head>
<body>
<label><input type="radio" name="gender" id="male"> Male</label>
<label><input type="radio" name="gender" id="female"> Female</label>
<button type="button" class="check-male">I'm Male</button>
<button type="button" class="check-female">I'm Female</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 [email protected]
Ajax Image Upload using Intervention Package in Laravel
Today, I will learn you how to store fil...Simple Parallax Scrolling Effect with Parallax.js
There are lots of Javascript and jQuery...How to Remove an Event Handler in jQuery
Use the jQuery off() Method You can s...Laravel 8 Create Unique Slug Tutorial Example
In this article, we will provide example...How to Generate Unique slug in Laraval 7.x Example
Want to engender unique slug in Laravel?...