odd selector in jQuery with example

  1. odd selector selects all the elements at odd position in the page. 
  2. The odd selector can be used to apply CSS to odd tr's of a table.

Example :

    <title>odd 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">
    <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 odd selector. Odd selector selects all the elements at odd place in the page. In above example, it selects all the p elements at odd position and applies CSS to all of them.


Post a Comment