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.
posted by lychee to computers & internet (3 comments total)
<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.
if( !document.links ) { document.links = document.getElementsByTagName("superscript"); for (var ti=0;ti<document.subscripts.length;ti++) { var lnk = document.subscripts[ti]; document.links = lnk.getElementsByTagName("a"); } for (var ti=0;ti<document.links.length;ti++) { var lnk = document.links[ti]; if (lnk.title) { lnk.setAttribute("nicetitle",lnk.title); lnk.removeAttribute("title"); addEvent(lnk,"mouseover",showNiceTitle); addEvent(lnk,"mouseout",hideNiceTitle); addEvent(lnk,"focus",showNiceTitle); addEvent(lnk,"blur",hideNiceTitle); } } }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