How to use Checkbox Selector Method in JQuery

This article describe about checkbox Selector Method in JQuery.
  • 1590

Use :checkbox Selector method in jQuery

We select specified input elements with type="checkbox".

This method select the checkbox type value for input element.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $(":checkbox").wrap("<span style='background-color:yellow' />");

    });

</script>

</head>

<body>

<form action="">

Name: <input type="text" name="user" />

<br />

I have a one book:

<input type="checkbox" name="book" value="one" />

<br />

I have a two book:

<input type="checkbox" name="book" value="two" />

<br />

I have many books:

<input type="checkbox" name="book" value="many" />

<br />

<input type="submit">

</form>

</body>

</html>

Output

op1.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.