I am want to replace a icon (Font Awesome) with an other.
I try this :
const toolbar1 = document.querySelector("#toolbar1");
const iconToReplace = toolbar1.querySelector(".fa fa-arrows-alt");
iconToReplace.innerHTML = '<i class="fa-fa-compress"></i>';
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
But it didn’t work.
Is there a solution?
Thanks !
2
Answers
Your selector within the
.querySelector()
call seems invalid, it should be:Furthermore, depending on the structure of the HTML, you may have intended to replace the class name of the selected element, instead of replacing the inner content of it:
Also, you are not actually using jQuery at all in your code – is it a requirement to use it?
Update the below code with your code.