用jQuery删除类 [英] remove class with jquery

查看:110
本文介绍了用jQuery删除类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我的项目有问题:
我想删除自己的dom中的头等舱:

 <   div     id   ="  > 
  <   div     ="   a" <  > ; 
  <   div     ="   a" <  > ; 
  <   div     ="   b" <   > 
  <   div     ="   b" <   > 
  <   div     ="   c" <   > 
  <   div     ="   c" <   > 
<  /div  >  


我的代码是重复的,因此我想删除重复类的第二个元素或第一个元素.
请帮帮我!

解决方案

jQuery的独特"功能可能会在这里为您提供帮助.

链接 [


Hi all!
I have an problem with my project:
i want remove the first class in my dom:

<div id="bottom_main">
  <div class="a"><div>
  <div class="a"><div>
  <div class="b"></div>
  <div class="b"></div>
  <div class="c"></div>
  <div class="c"></div>
</div>


My code is duplicate, so i want to remove the second element or the first element of duplicate class.
Please help me!

jQuery''s "unique" function may help you here.

link[^]


I''m using .slice() and .remove() of Jquery.


(".a").slice(0, 1).remove();--> Remove only the second div with class ".a"


这篇关于用jQuery删除类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆