Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all!
I have an problem with my project:
i want remove the first class in my dom:
HTML
<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
Updated 18-Dec-11 22:03pm
v2
Comments
Sergey Alexandrovich Kryukov 19-Dec-11 4:10am    
A class or a div? Both seems straightforward, so, what's the problem?
--SA
Sergey Alexandrovich Kryukov 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 19-Dec-11 23:16pm    
I want remove all the duplicate div

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

link[^]
 
Share this answer
 
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();
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900