How to hide the outer parents in Jquery -
below code, goal when user click <a>
in 'child_2', want hide $(this) class="parent". how can achieve this?
<div class="parent"> <div class="child_1"> </div> <div class="child_2"> <div> <ul> <li><a href="#">click me</a></li> <li></li> <li></li> <li></li> </ul> </div> </div> <div class="child_3"> </div> </div>
use closest
$(this).closest('.parent').hide();
for each element in set, first element matches selector testing element , traversing through ancestors in dom tree.
Comments
Post a Comment