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.

【備忘録】javascriptでフォームの選択値を取得する

Last updated at Posted at 2020-05-05

javascriptでフォームの選択値を取得する方法/設定する方法

プルダウン
html
<select id="pulldown">
  <option value="1">トマト</option>
  <option value="2">カボチャ</option>  
  <option value="3" selected>キュウリ</option>  
</select>
js(取得)
// JavaScript
var val = document.getElementById("pulldown").value;
// jQuery
var val = $("#pulldown").val();
js(設定)
// JavaScript
document.getElementById("pulldown").value = "2"
// jQuery
$("#pulldown").val("2")
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?