javascript - How do I use PHP to build a website menu with dynamic highlighting? -


i need change color of selected menu whenever page active , should stay until menu clicked.i have used jquery like

$('.navigation ul li a').click(function(){   $(this).css({"background-color":"#ffffff"});  $('.navigation ul li a').css({"background":"transparent"}); 

});

but works click function only.i need active till move menu .plz help!!!

php only

let assume website has following menu:

  • home
  • pistols
  • rifles

at top of home html page, insert:

<?php $this_page = "home"; ?> 

at top of pistols html page, insert:

<?php $this_page = "pistols"; ?> 

at top of rifles html page, insert:

<?php $this_page = "rifles"; ?> 

in css-file, add id, accompanying format, menu item page 1 displayed in browser. call id #cur_item, example.

edit navigation html this:

<ul class="navigation">     <li <?php if ($this_page == "home"):?> id="cur_item" <?php endif; ?> >         home     </li>     <li <?php if ($this_page == "pistols"):?> id="cur_item" <?php endif; ?> >         pistols     </li>     <li <?php if ($this_page == "rifles"):?> id="cur_item" <?php endif; ?> >         rifles     </li> </ul> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -