Reputation: 151
On the website I'm working on (http://easyspeedy.greenlevel.pl), I added some jquery to make an active class on the menu with the following code:
$("#menu li").click(function(){
//alert('hi');
$("#menu li").removeClass()
$(this).addClass("active")
}) ;
After I click on the menu, I can see the added class by using Chrome's check element function, but then it instantly disappears. I've used this code many times before, and it's always worked.
The second strange thing is on the bottom of the site, right above the footer, there's a background which is fixed positioned and it refreshes after about 5 sec; this occurs only on Chrome. How do I fix this?
Upvotes: 0
Views: 71
Reputation: 58490
Perhaps you're clicking a link in the menu and it's actually loading the linked URL?
If you want to prevent the link from loading, you need to call .preventDefault
doing something like this...
$("#menu li a").click(function (event) {
event.preventDefault();
});
Or perhaps I have misunderstood your problem. ;-)
Upvotes: 1
Reputation: 3312
The first one is simple. You have links in menu, so after you click on a li
element, it will change page location to the one in a
. Unless you have single-page application (and yours is not) you should set this class in the backend html template.
The second problem is more complex and probably the bug in Chrome. One solution could be (but i'm not sure) decreasing size of background image, as it's memory-related problem. Or you can simply not use fixed background image.
Upvotes: 1