change color of selected menu tab

后端 未结 3 1538
一向
一向 2020-12-21 12:14

I grabbed this snippet from another question:



        
3条回答
  •  囚心锁ツ
    2020-12-21 12:48

    You can actually greatly simplify your Javascript for this. This should achieve your desired effect.

    
    

    The Javascript here will do the following:

    • Add the "mouseover" class when you hover a link
    • Remove the "mouseover" class when you no longer hover a link
    • When you click a link, it will toggle the "clicked" class and remove it from any other link that may have had the class - this will restore your other tabs to their "normal" state.

提交回复
热议问题