kevinabraham kevinabraham - 1 year ago 129
Javascript Question

How to change button text to font awesome icon using jquery

I have a button

<button class="home-signup-button button-add" formnovalidate>Sign up</button>

On click of this button I want to change the text from Sign up to a font awesome icon.
<i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i>
. So far I've tried

$(this).text("<i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i>");

But I get an error that reads
Uncaught SyntaxError: missing ) after argument list
. If I just put in some text like "Connecting..." instead of the font awesome it works without any error.

Answer Source

instead of .text() use .html()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download