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.

要素の取得+CSS書き換え

Last updated at Posted at 2021-04-18

DOM (Document Object Model)

htmlで表現されている個々のオブジェクトを取得/操作したりできる

  • 要素の取得
  • getElementById(id);
  • 要素の作成
  • createElement(tag_type);
  • createTextNode(text);
  • 要素の追加
  • appendChild(element);

#jQueryの基本文法

$(document).ready(function(){
//ここにjQueryの処理を記述
});
$('要素').css('プロパティ','値');

テキストの色を変更する方法

<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="UTF-8">
    <title>Practice</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
  </head>
  <body>
    <h1 id="title">タイトル1</h1>
    <p id="element1">要素1</p>
    <p id="element2">要素2</p>
  <script>
    $(document).ready(function(){
      $('h1').css('color', 'red');
    });
  </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?