dp815292 2013-04-16 10:38
浏览 7

too long

I have following script that adds current class to <li> in a Joomla based website:

$(function(){
  $("#slide-menu > li ").click(function(e){
    e.preventDefault();
    $("#slide-menu > li ").addClass("current").not(this).removeClass("current");
  });
});

But when I click on the link page refresh and current class disappear Here is my html:

<ul id="slide-menu" class="menu menu-sidebar">
  <li class="level1 item187">
    <a class="level1" href="/plastikovye-okna-i-dveri/other/plastikovye-okna-i-dveri">
     <span>Пластиковые окна</span>
    </a>
  </li>
  <li class="level1 item188">
    <a class="level1" href="/plastikovye-okna-i-dveri-2/uncategorised/okna-rehau">
     <span>Входные двери</span>
    </a>
  </li>
</ul>
  • 写回答

2条回答 默认 最新

  • doulu1544 2013-04-16 10:42
    关注

    after the page refresh it will load everything again, so you can't keep it , but you can follow one of those three methods to achieve this:

    1. sending an ajax call to the server and save it there
    2. save the value to cookies and in your script when it loads it should check if that cookie exists and load the value from it
    3. match the current selected elements from the requested URL.

    Good luck

    评论

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计