jQuery(document).ready(function () {
var totaltr = $("#catlist_ul").html().find('a').length;
$('#cog1').hide();
var htmlBlock = "<strong>" + totaltr + " ITEMS</strong>";
totalProductList.innerHTML += htmlBlock;
});
<table id="catlist_ul">
<tr><td><a href="#">link</a><a href="#">link</a></td></tr>
<tr><td><a href="#">link</a><a href="#">link</a></td></tr>
</table>
Should return 4 ITEMS.
All you need is:
.html()gets theinnerHTMLof the provided selector, which is not what you want. Please review the jQuery APIInstead of using
jQuery(document).ready, you should use the aliasing shortcut: