简体   繁体   中英

How do you add a Fontawesome icon to a button in a JavaScript function

I am using emailjs and after the email is sent, my Fontawesome icon disappears. I tried a few things, but I can not seem to get the same icon back into the submit button.

It occurs in this line:

myform.find("button").text('<i class="fas fa-paper-plane"></i> Submit');

Currently, the output just displays the tag as text. I was hoping I could display the icon instead. Is there a JS trick that can get that to happen?

Thanks kindly.

Assuming myform is jquery object:

myform.find("button").html('<i class="fas fa-paper-plane"></i> Submit');

I only changed the .text function call to .html function call

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM