Home  >  jQuery

Example of :button Selector in jQuery

March 29, 2013
:button Selector selects all the button in our html code and we can apply any CSS to that group at any time with the help of jQuery. We use :button as
var but = $(":button").addClass("button");
 
In variable but, number all selected button is returned. Find the sample example below.

<!DOCTYPE html>
<html>
<head>
<style>
.button { background-color: red;}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>

<input type="button"/>
<input type="radio"/>
<input type="button"/>
<input type="checkbox"/>
<input type="button"/>

<div>
</div>
<script>

var but = $(":button").addClass("button");
$("div").text( "Number of button found:" + but.length);

</script>
</body>
</html>
 
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us