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>
.button { background-color: red;}
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

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


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


©2022 concretepage.com | Privacy Policy | Contact Us