/ Published in: JavaScript
HTML: <a href="#"></a>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function toggleTitle(b) { //alert(links.length); var spans = b.getElementsByTagName('span'); function removeChildrenFromNode(node) { if(node.hasChildNodes()) { while(node.childNodes.length >= 2) { node.removeChild(node.lastChild); } } } if (spans.length != 0) { removeChildrenFromNode(b); } else { if (b.hasAttribute('title')) {var annotationText = '<span class=\"annotation\"><br><i>Annotation: </i>'+b.getAttribute("title")+'</span>';} else {var annotationText = '';}; if (b.hasAttribute('keywords')) {var keywordsText = '<span class=\"authors\"><br><i>Authors: </i>'+b.getAttribute("keywords")+'</span>';} else {var keywordsText = '';}; if (b.hasAttribute('authors')) {var authorsText = '<span class=\"keywords\"><br><i>Keywords: </i>'+b.getAttribute("authors")+'</span>';} else {var authorsText = '';}; b.innerHTML += authorsText+"\n"+annotationText+"\n"+keywordsText; } }