如题,当前页面为 "/about" 时,就 active
<a href="#"{% if 当前路径 == "/about" %} class="active"{% endif %}>About</a>
类似上面这种,当前路径
如何获取?
如题,当前页面为 "/about" 时,就 active
<a href="#"{% if 当前路径 == "/about" %} class="active"{% endif %}>About</a>
类似上面这种,当前路径
如何获取?
javascruot
$(function(){
var href = location.href;
var x = href.match(/\/[\w\/]+$/);
if(x && x[0]){
$(".side-nav >li").find('a[href="'+x[0]+'"]').parent().addClass("active-nav");
}
});
简单又方便...
2 回答4.3k 阅读✓ 已解决
2 回答863 阅读✓ 已解决
1 回答4.1k 阅读✓ 已解决
3 回答858 阅读✓ 已解决
2 回答2.2k 阅读✓ 已解决
4 回答2.6k 阅读
3 回答907 阅读✓ 已解决
可以使用request.path
官方文档如下:
http://flask.pocoo.org/docs/0.10/api/#incoming-request-data
In this case the values of the above mentioned attributes would be the following:
url_root http://www.example.com/myapplication/