jQuery * Selector (original) (raw)

Last Updated : 01 Apr, 2024

The jQuery * selector selects all the elements in the document, including HTML, body, and head. If the * selector is used together with another element then it selects all child elements within the element used.

Syntax:

$("*")

Parameters:

Example 1: Selects all element and change background color.

HTML `

<script>
    $(document).ready(function () {
        $("*").css("background-color",
            "lightgreen");
    });
</script>

Welcome to geeksforgeeks

My name is akash.

I live in mathura.

My best friend is ajay.

Who is your favourite:

`

Output:

Example 2: Selects all element and change background color.

HTML `

<script>
    $(document).ready(function () {
        $("*").css("background-color",
            "green");
    });
</script>

GeeksForGeeks

cricket is religion in india

sachin is god of cricket.

records:

`

Output: