LoginSignup
6
2

More than 5 years have passed since last update.

Select2でいくつかのoption要素を選択状態にしておく方法

Posted at

Select2

Facebookライクなフォームを実現できるJSライブラリ。
検索もできて便利。
https://select2.github.io/

選択状態にする

割と簡単にできる

var values = [
    option要素のvalue属性の値,
    option要素のvalue属性の値,
    option要素のvalue属性の値];

$("#select").val(values).trigger("change");

とすると、選ばれたoption要素が選択状態になる。

6
2
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
2