John Smith John Smith - 1 year ago 95
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.

Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download