jQuery > Traversing methods

.parent() - Find parent element in jQuery

How to find the parent element of a particular element in jQuery?


To find the parent element of an element, parent() method can be used.

 <script>
      $("ul").parent().css("border", "2px dashed green ");
  </script>

Above code snippet will find the parent element of the “ul” element (In my case “ul” is kept under “div”, so it will apply the border css style width as 2px, border style as dotted and color as green).

 Views: 5340 | Post Order: 48



Write for us






Hosting Recommendations