在jQuery中,如果我有一个id为“parentId”的html选择,如何选择一个我知道选项值的选项?如何在HTML选择中选择一个我知道该值的选项?
这里是我的代码:
function selectParentId(parentId)
{
$('#parentId').find('option').each(function(index,element){
if(element.value == parentId)
element.prop('selected', true);
});
}
如何需要改变上面的代码?
复制 - > http://stackoverflow.com/questions/13343566/set-select-option-selected-by-value – adeneo