Hi,
I'm using latest jQuery (via the Google CDN) and am using this code to build a TOC:
$("#infoArticles h2, #infoArticles h3").each(function(i) {
var current = $(this);
current.attr("id", "title" + i);
$("#toc").append("<li><a id='link" + i + "' href='#title" + i + "' title='" + current.attr("tagName") + "'>" + current.html() + "</a></li>");
});
Works a treat.
I want the .each loop to treat matched h2's differently from matched h3's in order that I may add a class to the li's resulting from h2's.
Any helpful comments, most appreciated and gratefully received!