How do I get Nice Titles to apply to only the superscript tag?
October 6, 2005 11:44 AM Subscribe
Javascript newbie: I'm using Nice Titles for footnotes on a webpage. How can I get Nice Titles to apply only to links within the superscript tag and not to all links on the page?
I'm sure the solution is simple, but I've barely begun learning Javascript, and I'm stumped.
I'm sure the solution is simple, but I've barely begun learning Javascript, and I'm stumped.
Best answer:
posted by Khalad at 1:48 PM on October 6, 2005
for (var ti=0;ti<document.links.length;ti++) {
var lnk = document.links[ti];
if (lnk.title && lnk.parentNode.tagName.toLowerCase() == "sup") {
...
}
}
posted by Khalad at 1:48 PM on October 6, 2005
Response by poster: Thank you both very much! It works, it works!
posted by lychee at 2:18 PM on October 7, 2005
posted by lychee at 2:18 PM on October 7, 2005
This thread is closed to new comments.
<superscript>
<a href >something</a>
</superscript>
but not
<a href >somethingelse</a>
If so, what you're concerned with is this line:
document.getElementsByTagName("a");
That's operating on the whole document. You don't want that, you want to find a tags within superscripts. I -think- this is how that would be done. I'm not DOM guy but maybe this'll give you a better idea why it's working on some and not others.
posted by phearlez at 1:03 PM on October 6, 2005