0
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 1 year has passed since last update.

要素にまとめてstyleを追加、変更

Last updated at Posted at 2023-05-27

今まで使ってたのは

div.style.color = 'cyan'
div.style.fontSize = '14px'

一つずつ div.styleの続きを変えてたけど

div.setAttribute('style','color:cyan','font-size:14px')

element.setAttributeを使って一括で、cssに近い形でstyleを書ける

<div style = 'color:cyan;font-size:14px'> </div>

つまりこうなる

追記
style.cssTextってものがあるらしい
なにそれ便利すぎるでしょ

0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?