id selector in jQuery with example

id selector returns the element with the specified id.

Example :

    <title>ID Selector</title>
    <script type="text/javascript" src=""> 
    <script type="text/javascript">
    <div id="myDiv">This is div.</div>
    <button id="myButton">Click Me</button>
    <button onclick="location.reload()">Reset</button>

Demo :

In the above example, we have used ID selector. Id selector select the elements with the specified id on the page. In above example, it selects the elements with specified id and applies CSS to it.


Post a Comment