If I have the following
var url = this.data;
$.get(url, {}, function(data){
alert(data);
});
I'm successfully able to iterate through and alert the following:
<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>
However what I want to do is get the text between the <h3></h3>'s
Eg. Title 1, Title 2 etc. What is the best way to go about this?
alert($(data).filter('#arboretum-smith-box h3').text());
If you want the string "Title 1Title 2Title 3"
,
$(data).find('h3').text()
if you want the array(-like object) ["Title 1", "Title 2", "Title 3"]
,
$(data).find('h3').map(function(){return $(this).text();})
精彩评论