jQuery .class Selector
jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript. Elaborating the terms, it simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development.
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")Parameter:
- class: This parameter is required to specify the class of the elements to be selected.
Example 1:
HTML
<!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> |
Output:
Example 2:
HTML
<!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> |
Output:
Supported Browsers:
- Google Chrome
- Mozilla Firefox
- Edge
- Safari
- Opera


