Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aliasing Font Awesome Class

How do I properly Alisas a font awesome class such as fa fa-users to user ?

I am developing an Ext application, and I need to use font awesome icons, the following works for me:

<i class="fa fa-users"></i> 

However the icon to use is database result driven, hence I wish to use an alias class for fa fa-users, then I can switch classes dynamically. How do I do this.

Already tried:

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 using as:

<i class="user></i> 

But no icon appears, I just cant figure out what I am missing.

like image 512
Raghu Avatar asked Feb 16 '26 09:02

Raghu


1 Answers

you have to addClass to i instead

$('.users i').addClass('fa fa-users');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" />
<div class="users">
  <i></i> 
</div>
like image 112
dippas Avatar answered Feb 18 '26 23:02

dippas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!