Javascript - if statement not working?

前端 未结 5 994
生来不讨喜
生来不讨喜 2021-01-25 15:02

I\'m trying to set a class to active depending on the url. I\'m trying to use the code below, but in every case, it activates the active class for the second tab.

<         


        
5条回答
  •  野性不改
    2021-01-25 15:38

    if(pathname = '/learn/subsection2') { // assignment
    if(pathname == '/learn/subsection2') { // test for equality
    if(pathname === '/learn/subsection2') { // test for equality without type coercion
    

提交回复
热议问题