How to get the value of the selected item I know.
The problem is with what event to catch the selection of the item. If you use click() , the first item is selected. If you use change() , then vice versa, the first element can not be selected.
Are there any other options?

    3 answers 3

    Something like this:

     $("select").change(function(){ if($(this).val() == 0) return false; alert($(this).val()); }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <select> <option value="0">--Вы берите элемент--</option> <option value="1">Первый</option> <option value="2">Второй</option> </select> 
    http://jsfiddle.net/Y5LsD/2/

    • Yes, I know this option. =) But I thought maybe he could eat more civilized) - oleg_ismaylov
    • one
      By the way, how do you imagine yourself more civilized? - 11111000000

    If the user selects the same item in the list that was selected, then the change event does not occur, since nothing has changed. To always respond to an item selection, you can use the following:

     $('select option:selected').click(function(){ var value = $(this).val() || $(this).text(); console.log(value); }); 
    • 2
      Click does not always work, in the sense you can choose the keyboard. - zb '
     $('#select').on({ 'click': function(){ console.log($(this).val()); }, 'keyup': function(){ if(event.keyCode==13) console.log($(this).val()); }, }, 'option')