Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Select2ドロップダウンで「x」ボタンを押して、allowClearデフォルト(事前定義)値を有効に設定することは可能ですか?
allowClear
onchange イベントを使用します。値が空かどうかを確認し、値を定義済みのものに設定します。
$("select").on("change", function (e) { if($(this).val()==""){ $(this).val("predefined value"); } });