简体   繁体   English

如何使用jQuery删除标签

[英]How to remove the tag with Jquery

how to remove <br> an item with Jquery the item going after class <class="item"> ? 如何使用Jquery删除<br>类别<class="item">之后的<class="item"> I use $(".item > br").remove(); 我使用$(".item > br").remove(); but its not work 但它不起作用

The css selector > denotes an immediate child. css选择器>表示直接子代。 If you want a sibling (they have the same parent) immediately following the item, you can use the + selector. 如果您想要紧随该项目之后的兄弟姐妹(他们具有相同的父母),则可以使用+选择器。 You can find other useful selectors in the W3C specification . 您可以在W3C规范中找到其他有用的选择器。 Your could should therefore look like $(".item + br").remove(); 因此,您应该看起来像$(".item + br").remove(); assuming your html looks something like 假设您的html看起来像

<div class="item"></div>
<br />

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

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