Toggle font awesome class on button click

后端 未结 7 646
心在旅途
心在旅途 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:08

    .toggleClass() is a jQuery function and you're using it as JavaScript. Try this:

    $("#favIcon").toggleClass('fa-star-o fa-star');
    

提交回复
热议问题