John Smith John Smith - 4 months ago 19
jQuery Question

Behave differently when selecting a dropdown select by click or arrow keys

<select id="s">
<option value="1">selected1</option>
<option value="2">selected2</option>
<option value="3">selected3</option>
<option value="4">selected4</option>
<div id="se">

$('body').on('change', '#s', function() {
$('#se').text($('#s :selected').text()+" / unfortunatly it also triggers when Im moving with the UP and DOWN keys, not just with select");

I want this event triggered if I pick an item from the dropbox with mouseclick and not with UP and DOWN arrows.


Just use the "click" event on the select:

            var sv = $('#s').val();
            $('#se').html("That\'s it: "+sv);

Here there is a fiddle for it: