ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 访问页面对应的标题高亮显示

访问页面对应的标题高亮显示

原创 Linux操作系统 作者:wang_0720 时间:2017-08-07 14:19:31 0 删除 编辑
1 HTML

点击(此处)折叠或打开

  1. <div class="users-body">
  2.   <ul id="menu-list" class="trigger-menu list-inline">
  3.     <li>
  4.       <a href="/users/{{author_id}}?order_by=created_at" onfocus="this.blur()">文章</a>
  5.     </li>
  6.     <li>
  7.       <a href="/users/{{author_id}}" onfocus="this.blur()">动态</a>
  8.     </li>
  9.     <li>
  10.       <a href="/users/{{author_id}}?order_by=commented_at" onfocus="this.blur()">最新评论</a>
  11.     </li>
  12.     <li>
  13.       <a href="/users/{{author_id}}?order_by=top" onfocus="this.blur()">热门</a>
  14.     </li>
  15.     <li>
  16.       <a href="/users/{{author_id}}/following" onfocus="this.blur()">关注用户</a>
  17.     </li>
  18.     <li>
  19.       <a href="/users/{{author_id}}/followers" onfocus="this.blur()">粉丝</a>
  20.     </li>
  21.   </ul>
  22.   {% block user_content %} {% end %}
  23. </div>



2 js
$(function(){
    $(window).on("load hashchange",function(){
    $("#menu-list").find('a').each(function(){
      var url = window.location.protocol + '//' +  window.location.hostname + ':' + location.port
      if (url + $(this).attr('href') == String(window.location)) {
        $(this).addClass("active");
      }
    });
  });
});

3 css
.trigger-menu li a{
  font-size: 15px;
  font-weight: bold;
  color: #a3a3a3;
}

.trigger-menu li a:hover {
  box-shadow:  0 2px  #3d3d3d;
  color: #a6a6a6;
}

.trigger-menu .active {
  box-shadow:  0 2px  #3d3d3d;
  color: #3d3d3d;
}



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27181165/viewspace-2143189/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-05

  • 博文量
    111
  • 访问量
    953137