다양한 장소와 주소가있는 eachLocation
Div 중 일부를 반복해야합니다.다음 스팬 jquery를 선택하십시오
$('.eachLocation').each(function(index) {
var address=$(this).siblings().find('span.LocationAddress').text();
});
주소에 대한 값이 없습니다. ??? 내가 뭔가 잘못하고 있는거야?
<div class="eachLocation" >
<div class="LocationCounter">1.</div>
<div class="LocationInfo">
<span class="LocationName">Kay Kay Center</span><br/>
<span class="LocationAddress">
1019 fairfax road, Bellevue, NE 68005
</span><br/>
</div>
</div>
+1
- 경우 다른 사람이 누락, Senad 필터 상황에 맞는 매개 변수를 사용 하였다. '$ ('selector', context)'. 알아두면 아주 유용합니다! – mrtshermanhtml() 대신 text()를 사용할 수 있습니까? 어떤 차이가 있습니까? –
여기가 답을 찾을 수있는 곳입니다. http://api.jquery.com/text/ 기본적으로 text()는 모든 자식 요소에서 결합 된 텍스트 만 반환하고 html()은 html을 반환합니다. –