Skip to content
Advertisement

Javascript : How can i add “×” in a button using javascript

I have a java script code that when i click submit button it will add list in my List items. but i want my list to have and “X” button or specifically “×” for deleting purpose. my code goes like this :

JavaScript

But instead of getting the X button i want, i get a button like this:

this

Advertisement

Answer

First use × and not $times;.

Second, use .innerHTML and not textContent.

JavaScript
JavaScript
JavaScript

CSS Way:

You can find the Unicode for the character and use it with css. This is better as CSS is lighter compared to JS

JavaScript
JavaScript

Reference:

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