Toggle font awesome class on button click

后端 未结 7 609
心在旅途
心在旅途 2020-12-31 22:37

I have the code as here in this jsfiddle, I want the font awesome icon to change on button click using javascript, but it does\'nt seem to work. I\'m new to javascript so pl

7条回答
  •  一整个雨季
    2020-12-31 23:20

    Difster's response is correct. Here is how you can accomplish the same thing using native JavaScript:

    document.getElementById("favIcon").classList.toggle('fa-star-o');
    document.getElementById("favIcon").classList.toggle('fa-star');
    

提交回复
热议问题