LoginSignup
6
5

More than 5 years have passed since last update.

jQueryと複数選択リストの勉強

Last updated at Posted at 2014-08-31

jQueryをつかってselectタグで選択された値を取得する方法。

.val()で選択した値を取得できる。
.children(':selected').lengthで選択したリスト値の件数を取得できる。
.children(':selected').text()で選択したリスト値のラベルを取得できる。

画面

スクリーンショット 2014-08-31 17.35.22.png

Log

スクリーンショット 2014-08-31 17.35.34.png

サンプルコード

console.log($('#users').val());
console.log($('#users').children(':selected').length);
console.log($('#users').children(':selected').text());
6
5
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
6
5