If you're just needing some cross-browser DOM selection, there's no need to load jQuery.
Just load Sizzle instead. It's the selector engine that jQuery uses.
Example: http://jsfiddle.net/77bMG/
var headings = Sizzle('h1,h2,h3');
for( var i = 0; i < headings.length; i++ ) {
document.write('<br>');
document.write(i + ' is ' + headings[i].innerHTML);
}
Or without any library code, you can walk the DOM, and push the headings into an Array.
Example: http://jsfiddle.net/77bMG/1/
var headings = [];
var tag_names = {
h1:1,
h2:1,
h3:1,
h4:1,
h5:1,
h6:1
};
function walk( root ) {
if( root.nodeType === 1 && root.nodeName !== 'script' ) {
if( tag_names.hasOwnProperty(root.nodeName.toLowerCase()) ) {
headings.push( root );
} else {
for( var i = 0; i < root.childNodes.length; i++ ) {
walk( root.childNodes[i] );
}
}
}
}
walk( document.body );
for( var i = 0; i < headings.length; i++ ) {
document.write('<br>');
document.write(i + ' is ' + headings[i].innerHTML);
}