Reputation: 35
I have a file (aa.html) contains the following:
<p> Item1 </p>
<p> Item2 </p>
<p> Item3 </p>
I was able to read it using this:
$.get('aa.html', function(data) {
alert(data);
});
how can I know the number of Items inside (or count number of <p>
)?
Upvotes: 1
Views: 563
Reputation: 13542
$.get('aa.html', function(data) {
var dom = $('<div/>').append(data);
alert("# of <p> elements: " + dom.find('p').length);
});
Upvotes: 1