2012-09-26 22 views
6

Chcę usunąć div wewnątrz div z klasą chartsbar Oto mój kod htmlZnajdź div wewnątrz div i go usunąć?

<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> 

próbowałem

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

ale nie wydaje się działać.

Odpowiedz

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

To powinno działać!

Zachowaj to proste!

EDIT

Jeśli chcesz tylko usunąć pierwszy:

$('.chartsbar div:first').remove(); 
0

Spróbuj:

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

Lub:

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

Sprawdź FIDDLE.

0

Spróbuj z tym

$('.chartsbar').find('div:eq(0)').remove(); 

lub bezpośrednio korzystać

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

Możesz to osiągnąć za pomocą prostego selektora. Spowoduje to usunięcie pierwszego elementu div div.

$(".chartsbar > div:first-child").remove(); 
0

Spróbuj $('.chartsbar').children().first().remove()

Powiązane problemy