'How to edit a button element that was added as an appendChildElement(). and convert it to a font awesome icon

The document was added as using javascript:

      const task_edit_el = document.createElement("button");
      task_edit_el.classList.add("edit");
      task_edit_el.innerHTML = "Edit";

Now this creates a button element with the inner html Edit. how do i change the inner html to a font awesome icon? since its not showing on the normal html page. it is manipulated to mount when a button is clicked.



Solution 1:[1]

You need to create an "i" element inside in the button scope, after add class and finally add this i element to button element using add child.

<button><i class="fa-thin fa-alarm-clock"></i> Alarm</button>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paulo Henrique