Javascript HTML下拉列表将字典值设置为在jquery中选择的值
我有一个HTML下拉列表。下拉列表的数据源是字典。选定的值键将存储在隐藏字段中。在页面重新加载时,我想将字典中的值设置为下拉列表中的选定值。字典键将存储在隐藏字段中Javascript HTML下拉列表将字典值设置为在jquery中选择的值,javascript,jquery,html-select,Javascript,Jquery,Html Select,我有一个HTML下拉列表。下拉列表的数据源是字典。选定的值键将存储在隐藏字段中。在页面重新加载时,我想将字典中的值设置为下拉列表中的选定值。字典键将存储在隐藏字段中 var IxCustomer = $(_this.IxCustomerHiddenFieldId).val(); $(_this.CustomerSelectId).find("option[value=" + IxCustomer + "]").attr("selected", true); 我如何修改这个 这应该可以做到:
var IxCustomer = $(_this.IxCustomerHiddenFieldId).val();
$(_this.CustomerSelectId).find("option[value=" + IxCustomer + "]").attr("selected", true);
我如何修改这个 这应该可以做到:
$(_this.CustomerSelectId).val(IxCustomer);
设置
元素的值可以选择相应的选项。您可以将代码放入JSFIDLE吗?