Roger Wayne
Roger Wayne

Reputation: 429

Adding html entity to button text with javascript

I have button with some entity on it:

<button type='button' disabled class='buttonred' id="buttonred">&#10007;</button>

How can i change the button text to other entity?

document.getElementById('buttonred').text = '&#10004;'; 

Above will not work.

Upvotes: 0

Views: 1350

Answers (2)

Zakaria Acharki
Zakaria Acharki

Reputation: 67505

You should use innerHTML instead of text, Hope this helps.

document.getElementById('buttonred').innerHTML = '&#10004;';
<button type='button' disabled class='buttonred' id="buttonred">&#10007;</button>

Upvotes: 1

rraman
rraman

Reputation: 216

In this case to change from X in the button to a 'Tick' try using innerHTML.

document.getElementById('buttonred').innerHTML = '&#10004;';

fiddle for your reference http://jsfiddle.net/825sgc6x/

Upvotes: 0

Related Questions