admin管理员组文章数量:1336289
How would I make it so that the item that is clicked in the menu, stays highlighted blue. So basically the active menu item.
Fiddle
I've tried using css active, but im thinking I need javascript or something.
#cssmenu > ul li > a:active, #cssmenu > ul li:active > a {
color: #ffffff;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
background: #54cdf1;
background: -webkit-linear-gradient(#72d4f2, #54cdf1);
background: -moz-linear-gradient(#72d4f2, #54cdf1);
background: linear-gradient(#72d4f2, #54cdf1);
border-color: transparent;
}
How would I make it so that the item that is clicked in the menu, stays highlighted blue. So basically the active menu item.
Fiddle
I've tried using css active, but im thinking I need javascript or something.
#cssmenu > ul li > a:active, #cssmenu > ul li:active > a {
color: #ffffff;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
background: #54cdf1;
background: -webkit-linear-gradient(#72d4f2, #54cdf1);
background: -moz-linear-gradient(#72d4f2, #54cdf1);
background: linear-gradient(#72d4f2, #54cdf1);
border-color: transparent;
}
Share
asked Oct 3, 2013 at 18:47
user1938745user1938745
1932 gold badges5 silver badges16 bronze badges
1 Answer
Reset to default 4You'll need some JS for that.
$(document).ready(function() {
$("#cssmenu li").on("click", function() {
$("#cssmenu li").removeClass("active");
$(this).addClass("active");
});
});
Then just style #cssmenu li.active
the way you want it in your CSS.
本文标签: javascriptKeep active menu item highlightedStack Overflow
版权声明:本文标题:javascript - Keep active menu item highlighted - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742406507a2468930.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论