Stop Function?
Stop Function?
Is there a function to tell jquery to only do something on the first instance that matches then to stop.
For example I add a class to a LI to an UL with the below but it adds the LI to all ULs under it.
- $("div#container ul").prepend("<li>Home</li>");
Original code:
- <ul>
- <li>
- <ul>
- <li>item</li>
- </ul>
- </li>
- </ul>
Code needed:
- <ul>
- <li>Home</li>
- <li>
- <ul>
- <li>item</li>
- </ul>
- </li>
- </ul>
Currently Output code:
- <ul>
- <li>Home</li>
- <li>
- <ul>
- <li>Home</li>
- <li>item</li>
- </ul>
- </li>
- </ul>