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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -