jQuery > Traversing methods

.next() - Immediate next element in jQuery

How to find the immediate next element from the element found by the selector in jQuery?


To find the immediate next element from the element found by the selector, next() method can be used.

 <script>
      $("div li").first().next().css("border", "5px dashed green");
  </script>

Above code snippet will find the second “li” element under each “div” element (.first() method will find the 1st li element and .next() method will jump to the next matched element).

 Views: 10912 | Post Order: 47



Write for us






Hosting Recommendations