javascript - Unable to highlight the first element of a menu list -


i have list of menu below:

<ul id="tablist">     <li><a class="tab" href="#" onclick="return expandcontent('sc1', this)">menu1</a></li>     <li><a class="tab" href="#" onclick="return expandcontent('sc2', this)">menu2</a></li>     <li><a class="tab" href="#" onclick="return expandcontent('sc3', this)">menu3</a></li>     <li><a class="tab" href="#" onclick="return expandcontent('sc4', this)">menu4</a></li>     <li><a class="tab" href="#" onclick="return expandcontent('sc5', this)">menu5</a></li> </ul> 

on click menu item show div sc1,sc2,sc3,sc4,sc5 resp. javascript have used below:

var initialtab=[1, "sc1"]  function cascadedstyle(el, cssproperty, csspropertyns) {     if (el.currentstyle)         return el.currentstyle[cssproperty]     else if (window.getcomputedstyle) {         var elstyle=window.getcomputedstyle(el, "")         return elstyle.getpropertyvalue(csspropertyns)     } }  var previoustab=""  function expandcontent(cid, aobject) {     var links=document.getelementsbytagname("a");     for(i=0;i<links.length;i++) {         if(links[i].classname=="tab") {             links[i].style.fontweight="normal";         }     }     aobject.style.fontweight="bold";     if (document.getelementbyid) {         highlighttab(aobject)         detectsourceindex(aobject)         if (previoustab!="")             document.getelementbyid(previoustab).style.display="none"         document.getelementbyid(cid).style.display="block"         previoustab=cid         if (aobject.blur)             aobject.blur()         return false     } else         return true }  function highlighttab(aobject) {     if (typeof tabobjlinks=="undefined")         collecttablinks() }  function collecttablinks() {     var tabobj=document.getelementbyid("tablist")     tabobjlinks=tabobj.getelementsbytagname("a") }  function detectsourceindex(aobject) {     (i=0; i<tabobjlinks.length; i++) {         if (aobject==tabobjlinks[i]) {             tabsourceindex=i          }     } }  function do_onload() {     var cookiename=(typeof persisttype!="undefined" && persisttype=="sitewide")? "tabcontent" : window.location.pathname     var cookiecheck=window.get_cookie && get_cookie(cookiename).indexof("|")!=-1     collecttablinks()     inittabcolor=cascadedstyle(tabobjlinks[1], "fontweight", "fontweight")     inittabpostcolor=cascadedstyle(tabobjlinks[0], "fontweight", "fontweight")     if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck) {         var cookieparse=get_cookie(cookiename).split("|")         var whichtab=cookieparse[0]         var tabcontentid=cookieparse[1]         expandcontent(tabcontentid, tabobjlinks[whichtab])     } else         expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1]) }  if (window.addeventlistener)     window.addeventlistener("load", do_onload, false) else if (window.attachevent)     window.attachevent("onload", do_onload) else if (document.getelementbyid)     window.onload=do_onload </script> 

the divs follows:

<div id="tabcontentcontainer"> <div id="sc1" class="tabcontent"> <span style="font-size:9pt; color:black;">content 1 goes here</span> </div> <div id="sc2" class="tabcontent"> <img src="images/image.png"/> </div> <div id="sc3" class="tabcontent"> <span style="font-size:9pt; color:black;">content 3 goes here</span> </div> <div id="sc4" class="tabcontent"> <span style="font-size:9pt; color:black;">content 4 goes here</span> </div> <div id="sc5" class="tabcontent"> <span style="font-size:9pt; color:black;">content 5 goes here</span> </div> 

my problem unable highlight first menuitem bold when page loads i.e. want highlight menu1 default selected item when page loads. please out. in advance.

this want use:

ul li:first-child {    font-weight:bold; }  

jsfiddle


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -