众所周知,使用a标签跳转之后,会刷新一次,继而这个添加的样式就会消失。那么怎么解决这一问题呢?
<script>
$(function () {
$('.bar a').each(
function () {
if ($($(
this))[0].href ==
String(window.location))
$(this).addClass('active').attr('href', 'javascript:void(0);'
);
});
});
</script>
这样就好了
转载于:https://www.cnblogs.com/mica/p/11162480.html