jQuery :radio Selector


The :radio selector in jQuery is used to select input elements with type radio.

Syntax

The syntax is as follows −

$(":radio")

Example

Let us now see an example to implement the jQuery :radio selector −

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $(":radio").wrap("<span style='background-color:yellow'>");
   });
</script>
</head>
<body>
<h2>Register</h2>
<form action="">
Username: <input type="text" name="user"><br>
Set Password: <input type="password" name="password"><br>
Reserved:<input type="radio" name="category" value="r"><br>
Unreserved<input type="radio" name="category" value="u"><br><br>
<button type="button">Submit</button>
</form>
</body>
</html>

Output

This will produce the following output −

raja
Published on 05-Nov-2019 12:27:06
Advertisements