Skip to content
Advertisement

Trying to create an icon font awesome inside JS

I am trying to create a font awesome icon next to the list item, but it keeps giving me [object HTMLElement] any Idea why ?

//The icon add classes

JavaScript

Thank you

Advertisement

Answer

The right way to insert your icon is not

JavaScript

You should use li.appendChild(icon) instead. You can do the same with a textnode for your input text 🙂 Here’s my example, hopefully this is what you wanted : https://codepen.io/LENNY74/pen/dyNVVKa

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement