Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find div inside a div and remove it?

Tags:

jquery

I want to remove div inside the div with class chartsbar Here is my html code

<div class="chartsbar" style="position: absolute; bottom: 0px; left: 27.28%; display: none; height: 0%; background-color: rgb(7, 134, 205); color: rgb(255, 255, 255); width: 0.9730252100840335%; text-align: left; " rel="0" title="09-09-2012 - 0 (0%)">

<div style="text-align:center">
0
</div>

<span style="display: block; width: 100%; position: absolute; bottom: 0; text-align: center; background-color: #0786CD;">
09-09-2012
</span>

</div>

i tried

$('.chartsbar').find('div').first().remove();

but not seems to be working.

like image 850
Rakesh Sawant Avatar asked Sep 26 '12 06:09

Rakesh Sawant


2 Answers

$('.chartsbar div').remove(); 

It should work!

Keep it simple!

EDIT

If you only want to remove the first one:

$('.chartsbar div:first').remove(); 
like image 189
mbinette Avatar answered Nov 08 '22 10:11

mbinette


You can achieve this with a simple selector. This will remove the first div child.

$(".chartsbar > div:first-child").remove();
like image 42
Mark Avatar answered Nov 08 '22 11:11

Mark