# Font Awesome 5-Icon in JS verwenden

**URL:** https://meta.discourse.org/t/using-font-awesome-5-icon-in-js/108727
**Category:** Development
**Created:** [9. Februar 2019 um 02:29 UTC](https://meta.discourse.org/t/using-font-awesome-5-icon-in-js/108727 "2019-02-09T02:29:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zaino](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zaino/32/130057_2.png) [@zaino](https://meta.discourse.org/u/zaino)
#### Post date: [9. Februar 2019 um 02:29 UTC](https://meta.discourse.org/t/using-font-awesome-5-icon-in-js/108727/1 "2019-02-09T02:29:40Z")

</div>

I need some help here. I have read through all the threads regarding FA 5 and I am still not sure how to do this.

I want to use the FA icon as the link in an a tag within javascript. Here is how I would normally use the Twitter icon as the link, but it is not working:

```
if (userFields && userFields[userFieldId]) {
              const url = userFields[userFieldId];
              const link = "<a href='"+url+"' target='_blank'><i class="fab fa-twitter"></i></a>";
              return Ember.Object.create({ link, name: twitterUsernameField.get('name') });
            } else { ....

```

I am looking for a concrete example or the exact series of steps I need to take to get this to work.

Cheers

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [9. Februar 2019 um 15:38 UTC](https://meta.discourse.org/t/using-font-awesome-5-icon-in-js/108727/3 "2019-02-09T15:38:27Z")

</div>

Something like this should works, but remember to add the new icon in the site setting `svg icon`

```plaintext
 const link = "<a href='"+url+"' target='_blank'><svg class="fa d-icon d-icon-ICON-NAME svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#ICON-NAME"></use></svg></a>";

```
