0

I have this code which gets the html from another page

    $.get('alertjquery.html', null, function(tsv) {
     alert(tsv);
});

what I want to do know is count for the number of a certain element thats in the html page. I am a bit confused as if i did var data $('section').length; it wouldn't count the sections in the tsv but the sections in the current html page

this is the html page:

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>    
<script>

$(document).ready(function() {
    var data = $('#test').text($('section').length);
});

</script>
</head>
<body>
 <section>
 This should be counted
 </section>
 <section>
 This should be counted
 </section>
 <section>
 This should be counted
 </section>
 <section>
 This should be counted
 </section>
 <section>
 This should be counted
 </section>

  There are currently <b id='test'></b> alerts


</body>
</html>

When I alert this as tsv this also gets printed out However when I tried $tsv.find("section").length it returns 0

user3328513
  • 189
  • 1
  • 3
  • 12