开发者

dropdown onchange event not working

开发者 https://www.devze.com 2023-02-22 17:29 出处:网络
my dropdown list event onchange doesn\'t work in server while it works fine on my localhost. I\'m using jquery. what would be the reason.

my dropdown list event onchange doesn't work in server while it works fine on my localhost. I'm using jquery. what would be the reason.

html:

<select name="cities" id="cities" onchange="change_city();">
<option value="Basel" selected="selected">Basel</option>
<option value="Bern">Bern</option&g开发者_JAVA百科t;
<option value="Fribourg">Fribourg</option>
<option value="Geneva">Geneva</option>
<option value="Lugano">Lugano</option>
<option value="Zurich">Zurich</option>

</select>

jQuery:

function change_city(){
    var home_city =$("#cities option:selected").val();
    $.cookie("home_city", home_city, { expires: 3650, path: '/' });
    location.reload( true );

}


Test this:

<select name="cities" id="cities">
<option value="Basel" selected="selected">Basel</option>
<option value="Bern">Bern</option>
<option value="Fribourg">Fribourg</option>
<option value="Geneva">Geneva</option>
<option value="Lugano">Lugano</option>
<option value="Zurich">Zurich</option>
</select>

JQuery:

$('#cities').change(function(){
    var home_city =$("#cities option:selected").val();
    console.log(home_city);
    $.cookie("home_city", home_city, { expires: 3650, path: '/' });
    location.reload( true );

});
0

精彩评论

暂无评论...
验证码 换一张
取 消