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.