0
0

Javascriptでこれ知ってますか?直接idのvalue指定で表示変更?

Last updated at Posted at 2024-07-28

https://developer.mozilla.org/ja/play
のサイトで偶然下記のようにjavascriptを入力したら
getElementById を使わなくても id 属性で要素を指定できる。
一般的な記述
HTML

<textarea name="textarea"  id="city" rows="5" cols="15">ここに何か書いてください</textarea>

Javascript

const cityx = document.getElementById("city")
cityx.value = "新たなデータ"

city.value = "新たなデータ"

だけで表示された!!

参考サイト:
https://mseeeen.msen.jp/elements-can-be-referenced-without-using-getelementbyid/

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