i need to highlight the current page in navbar.!!its work!! but i extends new html page the navigation bar can't show ????

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

i need to highlight the current page in navbar.!!its work!! but i extends new html page the navigation bar can't show ????

varun kishore Ravi
<div>
  <nav>
    <ul class="nav">
      <li class="active"><a href="{% url 'dashboard' %}">DASHBOARD</a></li>
      <li><a href="#">EVENT</a></li>
      <li><a href="#">LOBBIES</a></li>
      <li><a href="#">MARKET</a></li>
      <li><a href="#">ONLINE PLAYERS</a></li>
      <li><a href="#">SUBSCRIBE</a></li>
    </ul>
  </nav>
</div>

<script type="text/javascript">
$(function () {
    setNavigation();
});

function setNavigation() {
    var path = window.location.pathname;
    path = path.replace(/\/$/, "");
    path = decodeURIComponent(path);

    $(".nav a").each(function () {
        var href = $(this).attr('href');
        if (path.substring(0, href.length) === href) {
            $(this).closest('li').addClass('active');
        }
    });
}    
</script>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2eaaf0c0-7d84-4807-823e-baafdec70cc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.