jQuery #id Selector (original) (raw)

Last Updated : 11 Jul, 2025

jQueryis 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 on the terms, it simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development.

The #id selector specifies an id for an element to be selected. It should not begin with a number and the id attribute must be unique within a document which means it can be used only one time.

Syntax:

$("#id")

Parameter:

Example 1:

HTML `

GEEKS FOR GEEKS

jQuery|#id selector

`

Output:

Example 2:

HTML `

ID
    <p>id="DIV1"</p>

</div>
<div id="DIV2">id="DIV2"</div>
<script>
    $("#DIV2").css("border",
        "2px solid yellow");
</script>

`

Output:

Supported Browsers: