无法使用 jQuery 在按钮内添加很棒的字体

Unable to add font awesome insid a Button using jQuery

我有以下按钮:-

<button id="show" style="background:#4d9b84" class=" btn btn-primary">Click here to learn more</button>

我写了下面的 jQuery 来将按钮的文本从“点击这里了解更多”更改为使用超棒字体的上箭头,如下所示:-

$("#show").click(function () {
                    $("#show").html("<i class=\"fa fa - arrow - up\" aria-hidden=\"true\" style=\"color:#2ebdbe!important\"></i>");
                }
            });

但是当我点击如下按钮时,我得到一个空按钮:-

关于如何使用 jQuery 在按钮内添加超赞字体图标,请给我任何建议? 谢谢

您的 class 名称中有空格,应该是 fa-arrow-up。

您需要删除 class 名称中的空格:

  $("#show").html("<i class=\"fa fa-arrow-up\" aria-hidden=\"true\" style=\"color:#2ebdbe!important\"></i>");