Mon, 2011-11-21 09:49
Dear Sir,
These codes work fine
<li><a href="" onclick="document.getElementById('div2').style.display='none';return false">Hide Div 2</a></li>
If use these line, then it do not work
<li><a href="" onclick="document.getElementById('div2','div3','div4','div5').style.display='none';return false">Hide Div 2</a></li>
I used more than one div in it.
Complete discussin is here
http://www.webdevforums.com/showthread. ... w-Hide-Div
Please help
Mon, 2011-11-21 12:18
#1
Hi tqmd1, You can only get
Hi tqmd1,
You can only get one element at a time with getElementById.
So you will need to wrap it in a for loop or something.
Instead of calling getElementById call you own function that does the work for you.
Something like this should be close.
<li><a href="" onclick="hideStuff();return false">Hide Div 2</a></li>
function hideStuff(){ var stuff = new Array('div2','div3','div4','div5'); for(var i =0; i < stuff.length; i++){ document.getElementById(stuff[1]).style.display='none'; } }