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
.toggleClass() is a jQuery function and you're using it as JavaScript. Try this:
.toggleClass()
$("#favIcon").toggleClass('fa-star-o fa-star');