Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a html unicode onto createTextNode

So I've got a span

<span class="delete-btn">&#x2718;</span>

and am trying to include the HTML unicode for x - &#x2718; within a textNode -

span.appendChild(document.createTextNode("&#x2718;"));

however this simply isn't working. Any ideas?

like image 956
codfish555 Avatar asked Oct 27 '25 03:10

codfish555


1 Answers

You can simply use \u2718 :

let span = document.getElementsByClassName('delete-btn')[0];
span.appendChild(document.createTextNode('\u2718'));
<span class="delete-btn">&#x2718;</span>
like image 60
Zenoo Avatar answered Oct 28 '25 17:10

Zenoo