如何使用jquery设置带有文字的字体真棒图标

问题描述 投票:1回答:1

我曾经使用jquery将字体真棒图标设置为div,但失败了。我需要在具有某些样式的给定文本“ Web Frameworks”之前设置字体真棒图标。这是jquery行。

$('#webTitle').html("Web Frameworks");

这是我需要插入的超棒字体图标。

<i class="fa fa-bar-chart fa-2x" aria-hidden="true" style="padding-right: 20px;"></i>

谁能建议最好的方法吗?

html jquery css font-awesome
1个回答
1
投票

您只可以在<i>函数中包含.html()标签,这是一个有效的代码段:

.html()
$('#webTitle').html('<i class="fa fa-bar-chart fa-2x" aria-hidden="true" style="padding-right: 20px;"></i>Web Frameworks');
© www.soinside.com 2019 - 2024. All rights reserved.