xxxxxxxxxx
$('#id').children(':selected').text();
xxxxxxxxxx
// Get the selected text from the dropdown
const selectedText = $("select option:selected").text();
// Print the selected text
console.log(selectedText);
xxxxxxxxxx
$("#myDropdown option:contains(Option 2)").attr('selected', 'selected');
xxxxxxxxxx
// Getting the selected option text
var selectedOptionText = $("select option:selected").text();
// Outputting the selected option text
console.log(selectedOptionText);