Hi.
I'm sorry if this question is too amateur.
I'm just appying some inherited code and I'm not a JS professional.
So, I ask for your help.
I'm doing a top menu that show and hides several div:
When the page load, all div are hidden with a "display none" css line, and there is a background image.Code:<script type="text/javascript" language="JavaScript"><!-- function HideAllShowOne(d) { // Between the quotation marks, list the id values of each div. var IDvaluesOfEachDiv = "id1 id2 id3 id4 id5 id6"; //------------------------------------------------------------- IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/[,\s"']/g," "); IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/^\s*/,""); IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/\s*$/,""); IDvaluesOfEachDiv = IDvaluesOfEachDiv.replace(/ +/g," "); var IDlist = IDvaluesOfEachDiv.split(" "); for(var i=0; i<IDlist.length; i++) { HideContent(IDlist[i]); } ShowContent(d); } function HideContent(d) { document.getElementById(d).style.display = "none"; } function ShowContent(d) { document.getElementById(d).style.display = "block"; } function ReverseDisplay(d) { if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; } else { document.getElementById(d).style.display = "none"; } } //--></script>
Can I show the first div when the page loads and hide it when someone clicks on the menu to view the other divs?
If I change the div visibility on the css, it remains always visible.
I believe that some modification on the script could do that, but I don't know how to do it.
Thank you for your help


Reply With Quote
and it's working the way I wanted.
Bookmarks