Click here to Skip to main content
11,577,710 members (41,631 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML jQuery DOM
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!
Posted 18-Dec-11 21:56pm
Edited 18-Dec-11 22:03pm
Mehdi Gholam280.8K
v2
Comments
SAKryukov at 19-Dec-11 4:10am
   
A class or a div? Both seems straightforward, so, what's the problem?
--SA
SAKryukov at 19-Dec-11 4:12am
   
Also, how come you created the duplicate in first place? If this is a bug, just fix it.
--SA
NguyenVanDuc at 19-Dec-11 23:16pm
   
I want remove all the duplicate div
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

link[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I'm using .slice() and .remove() of Jquery.
$(".a").slice(0, 1).remove();--> Remove only the second div with class ".a"
$(".a").slice(a, b).remove()--> Remove all div with class ".a" from a to b.
$(".b").slice(0, 1).remove();
$(".c").slice(0, 1).remove();
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 180
1 Peter Leow 180
2 Richard MacCutchan 125
3 Abhinav S 125
4 OriginalGriff 115
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 681
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100