kevinabraham kevinabraham - 2 months ago 29x
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.


instead of .text() use .html()