li menu needs class of “selected”

前端 未结 7 1473
抹茶落季
抹茶落季 2021-01-15 18:20

when the user clicks on a menu tab i want it to remain selected with it a white button.

here is my attempt but its not working. if you click the home button it does

相关标签:
7条回答
  • 2021-01-15 18:44
    1. You have no css for '.selected'. So, add the styling to turn the button white.

    2. Your jQuery is incorrect. In the click function, target 'this' because that targets the specific element that you clicked.

      $('#navigation li').click(function(event) {
         $(this).addClass('selected');
      });
      
    0 讨论(0)
提交回复
热议问题