include - Change active link inside JavaScript inlcude file -


i'm using javascript(js) includes render tab menu in few html pages. js includes working fine - tabs render. however, change background color of tab when page active. know how this? of files external files (i.e. external css , js files).

the provided snippet of code. suggestions appreciated.

// javascript document  document.write('<ul id="tabmenu">'); document.write('<li><a id="sbac" href="sbac_courses.html"><img src="../images/rlbm.png" width="149" height="52" /></a></li>'); document.write('<li><a id="nbm" href="nbm.html"><img src="../images/nbm.png" width="149" height="52" /></a></li>'); document.write('<li><a id="sbo" href="sbo.html"><img src="../images/sbo.png" width="149" height="52" /></a></li>'); document.write('</ul>');   switch (selected) {         case 'sbac':             $('ul li a').css('bgcolor','#fcb314');             break;         case 'nbm':             $('ul li a').css('bgcolor','#fcb314');             break;         case 'sbo':             $('ul li a').css('bgcolor','#fcb314');             break; } 

you may have massage pathname bit like

var page = location.pathname; //parse page ex: nbm.html $('#tabmenu [href="' + page + '"]').closest('li').css('background-color','#fcb314'); 

your above code seems not working because you're using 'bgcolor' instead of 'background-color'


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -