Coding

The #id Selector – jQuery Tutorial

Task

The #id Selector

Description

The jQuery #id selector uses id attribute of HTML tag to find the specific element.
An id should be unique within the page so you should use the #id selector when want to find the single and unique element.
To find the element with the specific id, write the hash character followed by the id of the HTML element:

$("#test")

Example

In this example when a user clicks on the button the element with id=”test” will be hidden:

<script>
$(document).ready(function(){
    $("button").click(function(){
        $("#test").hide();
    });
});
</script>

Try It Yourself - Online Compliler >>