19
21

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

JavaScriptを使った要素の取得方法

Last updated at Posted at 2017-06-13

body要素を取得する

document.body;

IDを指定して取得する

document.getElementById('ID名');

タグを指定して取得する

document.getElementsByTagName('タグ名');

クラスを指定して取得する

document.getElementsByClassName('クラス名');

name属性を指定して取得する

document.getElementsByName('name属性');

カスタムデータ属性から取得する

document.querySelectorAll('[データ属性]');
19
21
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
19
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?