Jquery click behaviour
Posted
by VP
on Stack Overflow
See other posts from Stack Overflow
or by VP
Published on 2010-03-25T22:10:19Z
Indexed on
2010/03/25
22:13 UTC
Read the original article
Hit count: 349
jQuery
|JavaScript
I'm developing a menu. This menu, will change the background image when you click on a link, as almost all menus does. if i click in one link from the menu, this link backgroun will change the color.
My jquery script is:
$(function() {
$('#menu ul li').click(function() {
$('#menu ul li').removeClass("current_page_item");
$(this).addClass("current_page_item");
//return false;
});
});
today, with the "return false" commented, when i click on the link under "#menu ul li" it changes the background open the new page and the background is reseted. For sure, if i uncomment the return false, the background works fine but then i cannot open any link. So its looks like after that i open a new page, it reset the classes. How can i make it persistent?
© Stack Overflow or respective owner