DOMで文字色を変える
プレビュー
↓スマートフォンの方はこちらからプレビューできます。
DOMで文字色を指定
コード
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>DOMで文字色を指定</title> <!--[if lte IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!--[if lte IE 9]> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <![endif]--> </head> <body> <h1 id="myid">DOMによる要素の指定</h1> <script> document.getElementById('myid').style.color = '#ff0000'; document.getElementById('myid').style.backgroundColor = '#eee'; </script> </body> </html>