last selector in jQuery with example

last selector returns the last element from the group of elements.

Example :

    <title>last Selector</title>
    <script type="text/javascript" src=""> </script>
    <script type="text/javascript">
    <p>This is first paragraph element.</p>
    <p>This is Second paragraph element.</p>
    <p>This is Thire paragraph element.</p>
    <p>This is fourth paragraph element.</p>
    <p>This is five paragraph element.</p>
    <button id="myButton">Click Me</button>
    <button onclick="location.reload()">Reset</button>

Demo :

In the above example, we have used last selector. Last selector selects the last element from the group of elements. In above example, it selects the last p element and apply CSS to it.


Post a Comment