LoginSignup
0
0

More than 1 year has passed since last update.

JavascriptでFont Awesomeのアイコンを生成する方法

Posted at

JavascriptのcreateElementで Font Awesomeのアイコン<i>を生成する方法のメモ。
Font Awesomeの読み込みができる状態で、<i>を生成した後にclass名をつけてあげればOKです。
https://fontawesome.com/icons

index.js
const div = document.getElementById('box');
const icon = document.createElement("i");
icon.className = "fas fa-exclamation-circle"; //アイコンのclass名
div.appendChild(icon);

簡単ですね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0