Open In App

jQuery multiple elements Selector

The jQuery multiple elements Selector is used to select multiple elements of an HTML document.

Syntax: 



$("element1, element2, element3, ...")

Parameter: 

Example 1: In this example, we will select the multiple elements by using jQuery multiple elements Selector.






<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
     
    <script>
        $(document).ready(function () {
            $("h2, div, span").css(
                "background-color", "green");
        });
    </script>
</head>
 
<body>
    <center>
        <h1>Welcome to GeeksforGeeks</h1>
        <h2>Geeks1</h2>
        <div>Geeks2</div>
        <p>Geeks3</p>
        <p><span>Geeks4</span></p>
    </center>
</body>
 
</html>

Output:

  

Example 2: In this example, we will select all the elements by using * selector. 




<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
     
    <script>
        $(document).ready(function () {
            $("*").css(
                "background-color", "green");
        });
    </script>
</head>
 
<body>
    <center>
        <h1>Welcome to GeeksforGeeks</h1>
        <h2>Geeks1</h2>
        <div>Geeks2</div>
        <p>Geeks3</p>
        <p><span>Geeks4</span></p>
    </center>
</body>
 
</html>

Output:

  


Article Tags :