Suppose it has the following html (1) structure.
From the $('.child') element I can access the $('.gran-parent') element , something like $('.child').parent().parent(); .
In any case, I do not think that this is a good way, because it is not general.
Suppose there are other divs between $ ('. Gran-parent') and $ ('. Child').
What is the most common way to access the first parent whose class is gran-parent , starting with $('.child') ?
<div class='gran-parent'> <div class='parent'> <div class='child'> </div> </div> </div>
source share