Reputation: 109
I try to set an option being selected via its value.My code is out here.It works in FF and Chrome but not in IE.can anyone help me?
var province = $("#hideProvince").val();
if(province != ""){
$("#province option[value='"+ province + "']").attr("selected", "selected");
}
Upvotes: 4
Views: 3328
Reputation: 337560
You can set val()
on the select
to update the selected option:
var province = $("#hideProvince").val();
if (province != ""){
$("#province").val(province)
}
Upvotes: 2