Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a li list on my page like
XML
<ul class="menu">
        <li><a  class="active" href="#about">About Me</a></li>
        <li><a href="#portfolio">My Portfolio</a></li>
        <li><a href="#contact">Contact Me</a></li>
      </ul>

and i want to change it class "active" which is present on my style.css file.
I use a jquiry
JavaScript
$('li').click(function () {
		    $(this).addClass('active').siblings().removeClass('active');
  //              $('li').removeClass();
  //             $(this).parent().addClass('active');
            });


but when i use this code then each tyme page was refress and go to the other page by 'a' tag where the css is not change.
how do i solve this problem.Please help me.
Thanks,
Manojit
Posted
Updated 14-Jan-13 23:54pm
v3
Comments
[no name] 15-Jan-13 2:06am    
You want to change the class of the li on clicking the li?
Manojit Mondal 15-Jan-13 2:42am    
Yes......

1 solution

Quote:
but when i use this code then each tyme page was refress and go to the other page where the css is not change.

Of course, dynamically set css properties are not persisted between calls.
So you either use HTML5 local storage[^] (if there is any), or you have to persist these changes on server side too: you can use an ajax call, to pass this change to the server, where it could be stored in a session variable for example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900