Hello everyone! I need help with toggling a font-awesome icon on a button using jQuery or JavaScript. I've tried using jQuery, but the previous icon doesn't get removed from the button when toggling to the new icon. Below is the code snippet:
<button class="btn btn-primary" id="share_screen_button" ng-click="share_screen()"><i class="fas fa-desktop"></i></button>
$scope.share_screen=async () => {
if ( $scope.roomObject === undefined) return;
if (screenShareObj === undefined) {
screenShareObj = await $scope.roomObject.createScreenShareObject();
$("#share_screen_button").removeClass("fas fa-desktop");
$("#share_screen_button").addClass("far fa-window-close");
} else {
screenShareObj.leave();
screenShareObj = undefined;
$("#share_screen_button").removeClass("far fa-window-close");
$("#share_screen_button").addClass("fas fa-desktop");
}
}
Can someone help me with resolving this issue? Thank you!