Selecting multiple from an html select element without using ctrl key

前端 未结 7 2191
灰色年华
灰色年华 2020-11-27 05:44

I\'ve come across various solutions to this issue on the net.

Basically, I find having to hold down ctrl a bit cheesy, and I want the select list to just select what

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 06:06

    For a pure js solution in chrome set the event listener on "onmouseup" instead. The event that resets the scroll to the first element is fired on the mouse up. So for example:

    element.onmouseup = function(event) {
        event.preventDefault();
        var st = this.scrollTop;
        setTimeout(function () { element.scrollTop = st; }, 0);
    };
    

提交回复
热议问题