I have an html select drop down that gets it's options populated from making an ajax call to the database. Users have the ability to press a button that then allows them to edit the text of the option and save it back to the database. After the user is done editing, I would like for the selected option to remain the one they just edited. Here is what I have
getSessions();
var opt = $("#ddlSessionList option[value='" + sessionId + ";" + group + "']");
opt.attr('selected', true);
It seems I did not provide enough information, otherwise the question may have been correctly resolved. All the answers would have worked, had I also mentioned this was inside a fancybox. Combining the answers here with an answer I recieved from a previous question Set fancybox to open on a different fancybox close, and also going from selecting the value to selecting the text, I arrived at
setTimeout(
function () {
$('#ddlSessionList option:contains('+sessionName()+')')
.prop('selected', true);
}, 200);