[JS]動的にCSSを適用
更新:2023-05-11
JS技術メモ!
動的にstyleを設定する。
element.style.backgroundColor = "red";
<例>
HTML
<p id="test">あいうえお</p>
JS
let element = document.getElementById("test");
element.style.backgroundColor = "red";
PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html,
動的にstyleを設定する。
element.style.backgroundColor = "red";
<例>
HTML
<p id="test">あいうえお</p>
JS
let element = document.getElementById("test");
element.style.backgroundColor = "red";
PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html, PHP,javascript,css,html,