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 3 years have passed since last update.

【JavaScript】DOM(Document Object Model)からHTMLとCSSを操作して、背景色、文字色、文字サイズを操作せよ。※css不要

Last updated at Posted at 2021-05-10

image.png

<!DOCTYPE html>
<html lang="ja">
<head>
   <meta charset="UTF-8">
   <title>challenge_dom</title>
</head>
<body>
   <div id="large">
       <div id="box1">文字色は赤文字サイズは24p</div>
       <div id="box2">文字色は白文字サイズはデフォルト</div>
   </div>
   <script>
       // ここに追記
       var large = document.getElementById('large'); // id="box1"の要素を取得
       var box1 = document.getElementById('box1'); // id="box1"の要素を取得
       var box2 = document.getElementById('box2'); // id="box2"の要素を取得

       large.style.backgroundColor = 'black';
       box1.style.color = 'red';
       box1.style.fontSize = "24px";
       box2.style.color = 'white';

   </script>
</body>
</html>

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?