如果我有以下
var url = this.data;
$.get(url, {}, function(data){
alert(data);
});
我成功地能够迭代并提醒以下内容:
<a href="javascript:void(0)" id="arboretum-smith" class="bullet" rel="251-195"> </a>
<div class="popup" id="arboretum-smith-box">
<h3>Title 1</h3>
<div class="popupcontent">
<p>Description text to go here.</p>
</div>
<a class="close" href="javascript:void(0)">Close</a>
</div>
<a href="javascript:void(0)" id="old-well" class="bullet" rel="251-245"> </a>
<div class="popup" id="old-well-box">
<h3>Title 2</h3>
<div class="popupcontent">
<p>Description text to go here.</p>
</div>
<a class="close" href="javascript:void(0)">Close</a>
</div>
<a href="javascript:void(0)" id="bell-tower" class="bullet" rel="100-100"> </a>
<div class="popup" id="bell-tower-box">
<h3>Title 3</h3>
<div class="popupcontent">
<p>Description text to go here.</p>
</div>
<a class="close" href="javascript:void(0)">Close</a>
</div>
但我想做的是在<h3></h3>'s
Eg之间获取文字。标题1,标题2等。最好的方法是什么?
答案 0 :(得分:1)
alert($(data).filter('#arboretum-smith-box h3').text());
答案 1 :(得分:0)
如果你想要字符串"Title 1Title 2Title 3"
,
$(data).find('h3').text()
如果你想要数组(类似对象)["Title 1", "Title 2", "Title 3"]
,
$(data).find('h3').map(function(){return $(this).text();})