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
You can use only Javascript:
function fav() { var icon = document.getElementById("favIcon"); if (icon.classList.contains("fa-star-o")) { icon.classList.remove("fa-star-o"); icon.classList.add("fa-star"); } else { icon.classList.remove("fa-star"); icon.classList.add("fa-star-o"); } }
example