简体   繁体   English

jQuery删除父cur.element的父

[英]jquery remove parent of parent cur.element

hi I don't remove parnet. 嗨,我不删除parnet。

My code: 我的代码:

  <div class="prdctfltr_add_scroll">
   <div class="prdctfltr_checkboxes">
      <label class="prdctfltr_ft_">
        <input type="checkbox" value="">
         <span>
            <img src="" onerror="delNoneOptionFilters(this)" class="product_filter_none_option">
            <script>function delNoneOptionFilters( x ){ $(x).closest('label').remove; }</script>
         </span>
      </label>
      <label class="prdctfltr_ft_popularity">
        <input type="checkbox" value="popularity">
        <span>Popularity</span>
      </label>
      <label class="prdctfltr_ft_rating">
        <input type="checkbox" value="rating">
        <span>Average rating</span>
      </label>
      <label class="prdctfltr_ft_date">
        <input type="checkbox" value="date">
        <span>Newness</span>
      </label>
        <label class="prdctfltr_ft_price">
        <input type="checkbox" value="price">
        <span>Price: low to high</span>
      </label>
      <label class="prdctfltr_ft_price-desc">
        <input type="checkbox" value="price-desc">
        <span>Price: high to low</span>
      </label>
   </div>
</div>

I want delete label class="prdctfltr_ft_" 我要删除标签class =“ prdctfltr_ft_”

remove is not a property It is a function you have to use like this $(x).closest('label').remove() . remove不是属性这是一个function ,你必须使用类似这样的$(x).closest('label').remove()

 function delNoneOptionFilters( x ){ $(x).closest('label').remove(); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="prdctfltr_add_scroll"> <div class="prdctfltr_checkboxes"> <label class="prdctfltr_ft_"> <input type="checkbox" value=""> <span> <button onclick="delNoneOptionFilters(this)">delete</button> </span> </label> <label class="prdctfltr_ft_popularity"><input type="checkbox" value="popularity"><span>Popularity</span></label><label class="prdctfltr_ft_rating"><input type="checkbox" value="rating"><span>Average rating</span></label><label class="prdctfltr_ft_date"><input type="checkbox" value="date"><span>Newness</span></label><label class="prdctfltr_ft_price"><input type="checkbox" value="price"><span>Price: low to high</span></label><label class="prdctfltr_ft_price-desc"><input type="checkbox" value="price-desc"><span>Price: high to low</span></label> </div> </div> 

请尝试:

function delNoneOptionFilters( x ){ $(x).parents('label').remove(); }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM