Net-informations.com
SiteMap  | About    

jQuery parent() vs. parents()



jQuery parent() method selects one element up the DOM tree. While jQuery parents() method travels up from the parent element and selects all the matching elements up to the document's root element .

jQuery parent() method

The parent() method traverses only one level up the HTML DOM tree . The optional parameters provide additional filtering options to narrow down the traversal.

example

run this source code Try it Yourself
  • Red
  • Blue

  • Green

Full Source

jQuery parents() method

The parents() method is used to find all the parent elements related to the selected element. This method traverse all the levels up the selected element and return that all elements .

example

Full Source










net-informations.com (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.