I have a select field with some options in it. Now I need to select one of those options with jQuery. But how can I do that when I only know the
select
options
.attr() sometimes doesn't work in older jQuery versions, but you can use .prop():
$('select#ddlCountry option').each(function () { if ($(this).text().toLowerCase() == co.toLowerCase()) { $(this).prop('selected','selected'); return; } });