1. 程式人生 > >jquery中當點選子節點時如何實現刪除父節點的問題

jquery中當點選子節點時如何實現刪除父節點的問題

參考文章:https://blog.csdn.net/sloafer/article/details/80103011

父節點的class="a",子節點的class="b",當點選子節點時刪除父節點,

function remove(){}裡怎麼實現

 

 

可以這樣做:

 

 
  1. $('.b').click(function(){

  2. $(this).closest('.a').remove()

  3. })

 

試了很好用。