Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome: Scroll on <select> triggers change() event

I have a <select> element with the multiple="multiple" attribute. In Chrome (v27), the change() event is getting triggered when the user scrolls by clicking and dragging using the mouse. Once a value has been selected, the problem ceases to exist.

Example Markup

<select multiple="multiple">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
</select>

Example jQuery

$('select').on('change', function() {
  alert('Changed!');
});

Is this a bug with Chrome? I've tried searching but haven't come across anything.

Here's a fiddle

like image 358
billyonecan Avatar asked Jun 03 '13 15:06

billyonecan


People also ask

How to throttle scroll event?

You could write a simple throttle debounce function to limit the times per second the scroll event will be handled. function debounce(method, delay) { clearTimeout(method. _tId); method. _tId= setTimeout(function(){ method(); }, delay); } $(window).


1 Answers

It is the bug in chrome

SELECT box with MULTIPLE option fires ONCHANGE event on scroll

and here

like image 80
PSR Avatar answered Oct 13 '22 03:10

PSR