0
如何使用jQuery從id = overall answer div中的評級選定div中獲取文本?jQuery按類選擇最接近的子元素
我想動態地從整個父div內的那個div取文本「TESTING」。
<div class='answer' id="overall">
<div class='rating'>1</div>
<div class='rating'>2</div>
<div class='rating'>3</div>
<div class='rating'>4</div>
<div class='rating selected'>TESTING</div>
</div>
<div class='answer' id="effort">
<div class='rating'>1</div>
<div class='rating'>2</div>
<div class='rating'>3</div>
<div class='rating selected'>4</div>
<div class='rating'>TESTING</div>
</div>
我試圖做到這一點,它是空白的。
$(document.getElementById('overall')).find('.rating selected').text();