dropdown onchange event not working
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 );
});
精彩评论