In jQuery, if I have an html select with an id of "parentId", how can I select an option where I know the option's value?
Here is the code that I have:
function selectParentId(parentId)
{
$('#parentId').find('option').each(function(index,element){
if(element.value == parentId)
element.prop('selected', true);
});
}
How do I need to change the above code?