我有一个字段:
<span>Color Set By</span>
<select class="full select" id="mapcolor">
<option value =1 selected >Difference in Final Price</option>
<option value =2 >Difference in Regular Price</option>
<option value =3 >Difference in Final Price/Shipping</option>
</select>
但是当另一个函数传递的选项值是2时,我需要更改以更改选择。以及取消选择之前的内容。它和下拉菜单。我的代码是正确的:
var mapid=getPresetFilters(mapcolor);
if(mapid!==$('select#mapcolor').val()) {
$("#mapcolor option[value=mapid]").attr("selected", "selected");
}