Return to Snippet

Revision: 26379
at April 28, 2010 15:29 by certainlyakey


Updated Code
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;
	}
}

Revision: 26378
at April 28, 2010 15:18 by certainlyakey


Updated Code
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 {
		var annotationText = b.getAttribute("title");
		var keywordsText = b.getAttribute("keywords");
		var authorsText = b.getAttribute("authors");
		b.innerHTML+="<span class=\"authors\"><br><i>Authors: </i>"+authorsText+"</span>\n<span class=\"annotation\"><br><i>Annotation: </i>"+annotationText+"</span>\n<span class=\"keywords\"><br><i>Keywords: </i>"+keywordsText+"</span>";
	}
}

Revision: 26377
at April 26, 2010 08:59 by certainlyakey


Initial Code
function toggleTitle(b) {
	var span = document.getElementById('norms_t1').getElementsByTagName('span');
	for (var i=0; i < span.length; i++) {
		var span = document.getElementById('norms_t1').getElementsByTagName('span')[i];
		var spanclass = span.getAttribute("class");
			if (spanclass == "annotation" ) {
				span.parentNode.removeChild(span);
		}
	}
	var annotationText = b.getAttribute("title");
	b.innerHTML+="<span class=\"annotation\"><br><i>Аннотация: </i>"+annotationText+"</span>";
}

Initial URL


Initial Description
HTML: <a href="#"></a>

Initial Title
Toggle hidden text inside multiple elements

Initial Tags
javascript

Initial Language
JavaScript