keydown event in drop down list

前端 未结 12 1586
日久生厌
日久生厌 2020-12-07 00:24

I am trying to create a Drop down list, that when a user holds the SHIFT key, it will select the same index on all other drop down lists.

Currently, I am doing the f

12条回答
  •  太阳男子
    2020-12-07 00:58

    Bryan, you can try the following way to do this. I tested on Jsfiddle it working in your way If I got your question correctly.

     var shifted = false;
    $(document).on('keyup keydown', function (e) { shifted = e.shiftKey; });
    
    $("select").on('keyup keydown',  function (e) {
        shifted = e.shiftKey;  
    });
        $('.report_info select').on('change',  function (e) {
            var cr = $(this).val();
            if (shifted) {
                $('.report_info select').each(function () {
                    $(this).val(cr);
                });
            }
        });
    

    Please let me know if it works for you.

提交回复
热议问题