Jquery.change firing on page load

Sha*_*ean 2 javascript jquery

<label for="AddList" class="locType">Select a location</label>
<select id="AddList">
     <option value="New">New Address...</option>
</select>
Run Code Online (Sandbox Code Playgroud)

The Js.

$(document).ready(function() {
    //Location Code
    $("#AddList").change(function() {
        var str = "";
        $("#AddList option:selected").each(function() {
            str += $(this).text() + " ";
        });
        alert(str);            
    })
    .change();
});
Run Code Online (Sandbox Code Playgroud)

I'm trying to alert the contents whenever the user selects an option in the combobox. Also, could the code be provided to get the value of the selected option also.

Thank you

Sam*_*son 6

You're calling .change(); yourself right after you bind it:

//Location Code
$("#AddList").change(function() {
    /* your logic */           
})
.change(); // right here you're calling it
Run Code Online (Sandbox Code Playgroud)

Getting the value of the option:

$("#AddList option:selected").each(function(){
  var val = $(this).val();
});
Run Code Online (Sandbox Code Playgroud)