> $('h1,h2,h3,h4').each(function(i){
> out += i + ': ' + this.nodeName + "\n";
> });
The problem is that the CSS selector: "h1,h2,h3,h4" means "find all h1
elements, then find all h2 elements, etc.". In that sense, hN elements
are particularly troublesome.
Since I don't know the actual structure of your HTML file, I'm just
going to offer one possible solution. Assuming a document structure
that's something l like this:
<div id="foo">
<h1>heading 1</ h1>
<h2>heading 1.2 a </h2>
<h3>heading 1.2.3 a </h3>
<h3>heading 1.2.3 b </ h3>
<h2>heading 1.2 b </h2>
<h3 >heading 1.2.3 c </h3>
<h3>heading 1.2.3 d </h3>
<h3>heading 1.2.3 e </h3>
<h2>heading 2 b </ h2>
</div>
You can do:
$("#foo > *").each(function(i){
out += i + ': ' + this.nodeName + "\n";
});
to achieve the desired result. I highly doubt that your document
actually looks like that, though - so it'll obviously need some
tweaking.
--John
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/