[英]How to change button text to font awesome icon using jquery
我有一个按钮<button class="home-signup-button button-add" formnovalidate>Sign up</button>
单击此按钮,我想将文本从注册更改为字体真棒图标。 <i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i>
。 到目前为止我已经尝试过了
$(".home-signup-button.button-add").click(function(){
$(this).text("<i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i>");
});
但是我Uncaught SyntaxError: missing ) after argument list
得到一个错误,它读取了Uncaught SyntaxError: missing ) after argument list
。 如果我只是输入一些文本,如“正在连接...”而不是字体真棒它没有任何错误。
而不是.text()
使用.html()
这是我的代码,我将如何做
$(".home-signup-button.button-add").click(function(){
$('#change').html("<i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i>");
});
一种解决方案是执行以下操作:
$(".home-signup-button.button-add").click(function(){
$(this).html("<i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i>");
});
你也可以这样做:
$(".home-signup-button.button-add").click(function(){
$(this).append($('i').addClass('fa fa-circle-o-notch fa-spin fa-3x fa-fw'));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.