Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a button value to contain an ampersand coded character via JavaScript

I'm trying to set a button value to be « (or ») via JavaScript with the following code:

document.getElementById('hideButton').value='«';

This just sets the button text to « rather than «.

The HTML markup works fine (i.e. <input type="button" value="&laquo;">) giving the double left arrow quote on the button face.

Is there some special way of escaping the ampersand code in JavaScript?

Thanks,

FM

like image 823
Fat Monk Avatar asked Dec 16 '22 00:12

Fat Monk


1 Answers

here just convert to UTF it should work.

document.getElementById('hideButton').value='\u00AB';
document.getElementById('otherButton').value='\u00BB';

here a link to convert special text

like image 121
Vivek Avatar answered Apr 13 '23 00:04

Vivek