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");
<!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>