i have a scheme on my page like this <div id="abc_alt">....</div> <div id="def_alt">....</div> <div id="123_alt">....</div> <div id="ad56_alt">....</div> Code (markup): i can close/open ( show/hide ) div from what i want hideLevel(levelId) Code (markup): on my page loaded, all divs are open. i want to close all divs at that moment. all divs has a same point as you can see. they ended with "_alt". how can i do that? sorry for my language.
Hi, You can use any numerical values for your divs like div0,div1 etc.. By this, you can easily get the count of the no. of divs and then use a for loop to generate the divid aslike for(var i=0;i<5;i++) { var divId = "div"+i; document.getElementById(divId).style.display = "none"; } Code (markup): this would ease the job than having a common prefix. Your option is also good, if you use some sort of numbers, it will be easy to generate the ID's. you can give this a try and leave me a feedback. In case of any other javascript topics, do checkout my blog at http://www.dsaravanan.wordpress.com/javascript/ regards d_s