jQuery > Traversing methods

.first() - Find the first element in jQuery

How to find the first element from the matched element in jQuery?


To find the first element from the group of matched element, first() method can be used.

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

Above code snippet will find firstli” element found under each “div” element of the web page.

 Views: 5291 | Post Order: 45



Write for us






Hosting Recommendations