Reputation: 281
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.
Upvotes: 8
Views: 34772
Reputation: 55750
Try:
$('.chartsbar > div').remove();
Or:
$('.chartsbar div').remove();
Check FIDDLE.
Upvotes: 0
Reputation: 5720
You can achieve this with a simple selector. This will remove the first div child.
$(".chartsbar > div:first-child").remove();
Upvotes: 3
Reputation: 28763
Try with this
$('.chartsbar').find('div:eq(0)').remove();
or directly use
$('.chartsbar div').remove();
Upvotes: 1
Reputation: 5094
$('.chartsbar div').remove();
It should work!
Keep it simple!
EDIT
If you only want to remove the first one:
$('.chartsbar div:first').remove();
Upvotes: 20