equal selector in jQuery with example

equal selector returns the elements at the specified index in the page.

Example :

    <title>equal Selector</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
    <script type="text/javascript">
    $("ul li:eq(3)").css({'font-size':'20px','background-color':'Orange'});
    <ul type="square">
    <li>Cesc Fabregas</li>
    <li>Thierry Henry</li>
    <li>Lionel Messi</li>
    <li>Zinedine Zidane</li>
    <button id="myButton">Click Me</button>
    <button onclick="location.reload()">Click Me</button>

Demo :

In the above example, we have used equal selector. Equal selector selects the element at the specified index in the page. Index starts from 0. In above example, it selects the li element at specified index and applies CSS to it.


Post a Comment