By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

Displaying "title" attribute under "a" element

P: 1
Being utterly useless when it comes to JavaScript, I come here for help with an issue that may or may not be an actual problem.

Say for example that I have a link that looks like thus:

Expand|Select|Wrap|Line Numbers
  1. <a href="language/lordprayer.html" title="A translation of the Lord's Prayer into Norda&thorn; and other Germanic languages in a side-by-side comparison">The Lord's Prayer</a>
Is there a way that I can take this title attribute show up under the hyperlink, not as a new paragraph, but as if it were separated with a <br /> tag? In essence this would be to avoid redundancies in having an attribute which shows up for, say, a blind-reader client, as well as showing up for the non-impaired viewer (I wouldn't want a reader to read similar lines next to each other).

Or rather, is this not a problem and should I avoid doing such a thing? Or is this merely impossible?
Sep 18 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
Expand|Select|Wrap|Line Numbers
  1. // a helper function
  2. function insertAfter(parent, node, referenceNode) {
  3.     parent.insertBefore(node, referenceNode.nextSibling);
  4. }
  5. // get all link elements
  6. var links = document.getElementsByTagName("a");
  7. for (i = 0; i < links.length; i++) {
  8.     // create a text node with the link title
  9.     title = document.createTextNode(links[i].title);
  10.     // insert after the link
  11.     insertAfter(links[i].parentNode, title, links[i]);
  12. }
May 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.