Trouble with jquery lavalamp

后端 未结 2 1803
心在旅途
心在旅途 2021-01-27 11:02

For some reason my background color shoots back to the leftmost link no matter what link I click on. Anyone know how to get it to stay on the clicked link?

css



        
2条回答
  •  梦谈多话
    2021-01-27 11:28

    You need to add the class current to the current li on the sub pages. The lavalamp plugin runs this bit of code:

    curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0];
    

    Which selects the li with a class of current or the first item. You can add this class on the server prior to sending to the client, no need to do it in javascript.

    Update

    This is what the HTML would look like for the navigation, when your browser is at the '/menu/' page. Notice how the li with the link to Menu has the class="current":

    
    

    On the EVENTS page, the li with the link to Events would have the class:

  • Events
  • etc.

提交回复
热议问题