Return to Snippet

Revision: 2128
at January 1, 2007 11:11 by alexwilliams


Updated Code
<a href="javascript:viewMore('two');" id="xtwo">... more</a>
<p>I see one.</p>
<p id="two" style="display:none">I see two.</p>


function viewMore(div) {
	obj = document.getElementById(div);
	col = document.getElementById("x" + div);
	
	if (obj.style.display == "none") {
		obj.style.display = "block";
		col.innerHTML = "... less";
	} else {
		obj.style.display = "none";
		col.innerHTML = "... more";
	}
}

Revision: 2127
at January 1, 2007 11:07 by alexwilliams


Initial Code
<a href="javascript:viewMore('two');" id="xtwo">... more</a>
<p>I see one.</p>
<p id="two" style="display:none">I see two.</p>


function viewMore(div) {
	obj = document.getElementById(div);
	col = document.getElementById("x" + div);
	
	if (obj.style.display == "none") {
		obj.style.display = "block";
		col.innerHTML = "... less";
	} else {
		obj.style.display = "none";
		col.innerHTML = "... more";
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
JavaScript automagically hide and show an HTML tag (DIV, P, whatever)

Initial Tags
javascript, html

Initial Language
JavaScript