Is there a way to create an alias for a Font Awesome class like fa fa-users
, and then switch between classes dynamically?
I'm working on a project where I need to use Font Awesome icons, and currently I have the following code:
<i class="fa fa-users"></i>
However, I want to use an alias class for fa fa-users
, as the icon to display is determined by database results. How can I achieve this?
I've already attempted the following methods:
Method 1
CSS:
.user
{
font-family: FontAwesome;
content: "\f095";
}
Method 2
Jquery Approach to alias class
$document.ready(function(){
$('.users').addClass('fa fa-users');
}):
In both cases, I tried using:
<i class="user></i>
But unfortunately, no icon appears. I'm struggling to figure out what I am missing.