I'm using this script to open different content in one div: http://www.pmob.co.uk/temp/3col-toggle-content3.htm
What I would like is to have the first textblock already visible when you open the page.
Any ideas?
| SitePoint Sponsor |
I'm using this script to open different content in one div: http://www.pmob.co.uk/temp/3col-toggle-content3.htm
What I would like is to have the first textblock already visible when you open the page.
Any ideas?

The most simple way to display the first DIV element is to use CSS and the :first-child pseudo selector, see the below example.
Code CSS:#collapseBlock div[id^=text]:first-child { display: block; }
Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
Having lame problems with your code? Let us help by using a jsFiddle
Thanks for your fast reply!
I'm afraid it didn't work for me though... should I add something to the html?





Code:hShow = function(nu) { var theTxt = document.getElementById("nav").getElementsByTagName("A"); for (var i=0; i<theTxt.length; i++) { if (i==nu){ click(theTxt[i]); } theTxt[i].onclick=function() { click(this); } } } function click(obj){ var theRef = obj.getAttribute('href'); var hash= theRef.indexOf('#')+1; var theDiv= theRef.substr(hash); theToggleDiv = document.getElementById(theDiv); var alreadyOn=0; var c = " " + theToggleDiv.className + " "; if (c.indexOf(" " + "over" + " ") != -1){alreadyOn = 1} if (!alreadyOn) { clearClasses();; theToggleDiv.className+=" over"} } function clearClasses(){ var navRoot = document.getElementById("collapseBlock"); for (j=0; j<navRoot.childNodes.length; j++) { var node = navRoot.childNodes[j]; if (node.nodeName=="DIV") { var x=node; x.className=x.className.replace(new RegExp(" over\\b"), ""); } } } window.onload = function(){ hShow(0); } // parameter 0 = the index number of the content to show
That did it brilliantly!!
thanks man![]()
Bookmarks