4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

css(styleタグ)をjavascriptで追加する

Posted at
// styleタグを作成
var styleTag = document.createElement('style');

// styleタグに記載するcssを記入
styleTag.innerText = `
    p {
       color:red;
    }
`;

// 作成したstyleタグを挿入
document.getElementsByTagName('head')[0].insertAdjacentElement('beforeend', styleTag);
4
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
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?