Source Code: (back to article)
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
</head>
<body>
<select>
<option value="0">Value1</option>
<option value="1">Value2</option>
</select>
<script>
let text = 'Value2';
$("select option").filter(function() {
//may want to use $.trim in here
return $(this).text() == text;
}).attr('selected', true);
</script>
</body>
</html>