0

I am getting stuck on this i want to get alert the whole value when user click with mouse suppose now i enter perston here when i click on first suggestion then it alert only perston. I don't know what i am doing wrong here is the screenshot. I want whole value in alert box but when i do with down arrow key and select first sugggestion and press tab it gives me right value in alert box. enter image description here

Here is my jquery Code:-

var location ="";
    $(document).on('change','#locationsearch',function(){
        location = $("#locationsearch").val();
        alert(location); return false;
    });

Thanks in advance. Helpful link must commented

kunal
  • 4,122
  • 12
  • 40
  • 75

1 Answers1

0

To get selected text, you should use

$("select option:selected").text();

If you have the value of the selected option, you can use this too:

$("#SELECT_ID option[value=VALUE]").text();

Milan Chheda
  • 8,159
  • 3
  • 20
  • 35