2013-08-05 65 views
-1
<span class="employeesList"> 
    <div class="hrEmployees"><span class="employeesSection">all categories <span class="pointerDown">&nbsp;</span></span></div> 
</span> 

我這樣做是爲了得到employeesSection不能得到孩子的價值觀jQuery中

$('.employeesList').children(':first-child').next().html(); 

內HTML,但多數民衆贊成在不工作...任何想法,我可能會做撥錯

回答

2

children(':first-child')選擇DIV,並next()嘗試選擇它的下一個兄弟姐妹,它不存在。

試試這個:

$('.employeesList').children(':first-child').children('span').html(); 
+0

嗯......讓我空 – Autolycus

1

您需要在這裏使用find方法。

$('.employeesList').children(':first-child').find('.employeesSection')html(); 

next用於同級元素的第一個孩子在這種情況下,沒有兄弟姐妹

您可以簡單地使用這個選擇

$('.employeesList').find('.hrEmployees > .employeesSection')html();