4

1 つのテキスト入力と 1 つの select2 要素 (バージョン 4.0.0) を持つフォームがあります。テキスト入力にフォーカスするときは、select2 を開きます。

これが私が試したことです:

<select list="userAccountsMap.values" listKey="accountNo" listValue="accountNo"/>
<input id="destinationAccount" type="text" name="destinationAccount">

<script type="text/javascript">

('select').each(function( index ) {
         $(this).select2();
     }
});

$("#destinationAccount").focus(function () {    
   $("select").trigger('select2:open');
});

</script>

しかし、それは仕事ではありません。ここでフィドルを参照してください:http://jsfiddle.net/Hatamikhah/73wypp1w/1/

私の問題が何であるかわかりません。

4

2 に答える 2

0

上記のコードは機能しますが、ほとんど変更はありません

このコードを変更 $("input").on("change", function () { $("#e1").select2("open"); });

このコードに対して、この機能を実行できます

$("input").on("click", function () {
    $("#e1").select2("open");
});
于 2016-05-17T07:14:03.580 に答える