1
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 1 year has passed since last update.

[JS]HTML要素の取得や書き換えをする

Last updated at Posted at 2022-01-31

HTML要素の取得や書き換えをすることで、イベント発火させると表示されている文字を変更することができるようになります。
#innerHTMLプロパティ
JavaScriptにて、HTML要素の取得や書き換えを行うことができるプロパティ。

HTML
<div class="contents" id="hoge">HTML</div>
javascript
const hoge = document.getElementById("hoge")

//HTML要素の取得
console.log(hoge.innerHTML)  // => HTML

//HTML要素の書き換え
hoge.innerHTML = "javascript"
console.log(hoge.innerHTML)  // => javascript

以上。
補足等ありましたらコメント頂けると幸いです。

1
0
1

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
1
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?