Setting HTML entity values (↑ ) to DOM dynamically (createElement)

If you try to create and add the element to DOM as below , it doesn't take the HTML entity codes like "↑" ,"↓" or char codes like  "↑" .

instead of Arrow marks

var buttonEl = document.createElement('input');
buttonEl.type = 'button';
buttonEl.value = '→'


Above code will just display as 

To display actually up arrow and down arrows like below use the unique code corresponding to them like below

for up arrow
buttonEl.value = '\u2191'

for downarrow
buttonEl.value = '\u2193'

No comments:

Post a Comment