php - Trouble with active element in my html page -


i'm looking method use css change display properties nav element related page active.

for example, if user on home page, 'home' button in navigation styled differently.

i use following code:

<li class="active">     <a href="<?php echo $sito ?>/index.php">home</a> </li> <li>     <a href="<?php echo $sito ?>/page1.html">page1</a> </li> <li>    <a href="<?php echo $sito ?>/page2.html">page2</a> </li> 

when selecte page1 or page2, home button remain active!

use this

var $links = $('li'); $links.click(function(){    $links.removeclass('active');    $(this).addclass('active'); }); 

demo


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -