LoginSignup
0
0

More than 5 years have passed since last update.

セレクトボックスの選択されている項目の取得

Posted at
<select id="hoge" name="test">
    <option value=1>foo</option>
    <option value=2>bar</option>
    <option value=3>baz</option>
</select>

セレクトボックスの、選択されている項目をあらわすセレクタは、

#hoge option:selected

値(1,2,...)を取得するには、

$("#hoge option:selected").val();

表示している文字列(foo,bar,...)の方を取得するには、

$("#hoge option:selected").text();
0
0
2

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