简体   繁体   中英

Make Navbar Active Link Background Color Remains Highlighted

I have code for side bar. I want the background of the link changes when I click it (background color automatically changes when I click either pegawai or absen). But with the javascript code like that, it always loading and the background color can't stay focused. How do I make background color for active bars?

活动链接的脚本

链接代码

It's not that simple because css can't retain the style if it's not initial style.
You need to adjust your jQuery code to check the url of the page also. You can utilize window.location.pathname And check if the current path name match with any link and add the css there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM