I'm looking to be able to switch between icons in Javascript while using the new FontAwesome SVG framework.
Previously in the old WebFont method, this was achieved by toggling or changing the class on the tag, however as these are now rendered as SVG's in the source code this no longer works.
Is there a way to do this without needing to render both SVG icons in source code and using additional classes/CSS to toggle display?
Font Awesome 5.0.0 has just been released and the migration from 4.7 to 5.0 wrecked up my javascript/jquery to change a "fa-star-o" icon to "fa-star" when the user clicks on it.
I managed to fix it so I wanted to share with you these two tips:
The icon in HTML:
1) Change icon with jQuery (from "star" to "alarm-clock" and vice versa):
2) Change icon-style with jQuery (from 'fas' to 'far'):
Hope that helps anyone with the same issue.