how to pass this element to javascript onclick function and add a class to that clicked element

前端 未结 6 1970
长情又很酷
长情又很酷 2021-01-30 19:21

I had an html navigation code as below

6条回答
  •  后悔当初
    2021-01-30 19:56

    You have two issues in your code.. First you need reference to capture the element on click. Try adding another parameter to your function to reference this. Also active class is for li element initially while you are tryin to add it to "a" element in the function. try this..

    
    
    
    

提交回复
热议问题