The jQuery :button selector selects button elements and input elements with type=”button”. The button element is not selected if we use input=” button” as a selector.
Syntax:
$(":button")
Example 1: In this example, we are using jQuery: button Selector.
HTML
<!DOCTYPE html>
< html >
< head >
< title >jQuery :button Selector</ title >
< script src =
</ script >
< script >
$(document).ready(function () {
$(":button").css(
"background-color", "lightgreen");
});
</ script >
</ head >
< body >
< center >
< form action = "" >
Name:
< input type = "text" name = "user" >
< br >< br > Password:
< input type = "password" name = "password" >
< br >< br >
< button type = "button" >
Button
</ button >
< br >< br >
< input type = "reset" value = "Reset" >
< input type = "submit" value = "Submit" >
< br >
</ form >
</ center >
</ body >
</ html >
|
Output:

Example 2: In this example, we are using jQuery: button Selector.
HTML
<!DOCTYPE html>
< html >
< head >
< script src =
</ script >
< script >
$(function () {
$(":button").css(
"border", "10px dashed green");
});
</ script >
</ head >
< body >
< input type = "button" value = "Test" />
< br >< br >
< input id = "txtName" type = "text" />
< input type = "submit" value = "Test" />
< br >< br >
< button id = "button1" >
This is a button
</ button >
< br >
</ body >
</ html >
|
Output:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
10 Jul, 2023
Like Article
Save Article