LoginSignup
0
0

More than 3 years have passed since last update.

初心者によるJavaScriptによるinput関連の操作の学習

Last updated at Posted at 2019-08-26

inputなどのフォーム等の操作についてのメモです。

inputの中身を取得するには

main.js
document.querySelector('input[type="text"]');

となる。
<input type="text" value="○○">のところを'input[type="text"]と[]を使って書くのは覚えておきたいです。

テキストエリアの場合は

main.js
document.querySelector('textarea');

ですね。

取得した要素について

main.js
  element.focus(); // フォーカスをあてる
  element.select(); // フォーカスをあて、全選択しておく
  element.disabled = true; // 入力させない

なんかもあります。

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