第1、直接给当前页面添加特殊样式,当网页刷新或者跳转到下一页后,样式消失;函数
第2、状况是即便刷新页面后样式仍然有效。直接上代码。this
第一种状况:对象
$(function(){
$('#profile-menu a').click(function(){
$('.current').removeClass('current');
$(this).addClass('current');
});
});rem
第二种状况:文档
$(function(){
$('#profile-menu a').each(function(){
if($(this)[0].href == String(window.location.href)){
$('.current').removeClass('current');
$(this).addClass('current');
}
});
});字符串