codeGK
Code it ALL
jQuery parents() - CodeGK

♦ jQuery parents()

♣ Example2: jQuery parents()

Below is the representation of jQuery parents() Syntax.
Basic Syntax
$(selector).parents().event(function(){
//code_block
});
Syntax Explanation:
selector : the element of which parents are to be selected
event : this can be events(click, hover, etc) or css or addClass, etc
code_block : code to executed on all parent tags
In this example, all the parent borders of level 4 are blue-colored, including the body and html tags.
Example
Input:
Output:
Ancestors