The .class selector specifies the class for an element to be selected. It should not begin with a number. It gives styling to several HTML elements.
Syntax:
$(".class")
Example-1:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $(".GEEKS").css("background-color" , "pink"); }); </script> </head> <body> <p class="GEEKS">Geeks For Geeks </p> <span class="GEEKS">jQuery|.class selector </span> </body> </html> |
chevron_right
filter_none
Output:

Example-2:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $(".GEEKS").css("background-color", "orange"); }); </script> </head> <body> <div style="border:2px solid red" class="GEEKS"> Geeks For Geeks </div> <br> <br> <span class="GEEKS">jQuery|.class selector </span> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers:
- Google Chrome
- Mozilla Firefox
- Edge
- Safari
- Opera
Recommended Posts:
- Not class selector in jQuery
- How to find the parent class name with known class in jQuery ?
- jQuery | :input Selector
- jQuery | :nth-of-type() Selector
- jQuery | :enabled Selector
- jQuery | element Selector
- jQuery | :last Selector
- jQuery | :button Selector
- jQuery | animated Selector with Example
- jQuery | :header Selector
- jQuery | #id Selector
- jQuery | :text Selector
- jQuery | :password Selector
- jQuery | :file Selector
- jQuery | :submit Selector
- jQuery | :checked Selector
- jQuery | :reset Selector
- jQuery | :selected Selector
- jQuery | :disabled Selector
- jQuery | :first-of-type Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

