how to get the value from placepicker while selecting on suggestion

88 views Asked by At

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

1

There are 1 answers

5
Milan Chheda On

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();