Please advice, how to find selected value of a html select on its change.
code is below
$(".js-CellFirst").change(function () {
alert($(this.find('option:selected')).text());<-- **trouble line**
});
thanks
Please advice, how to find selected value of a html select on its change.
code is below
$(".js-CellFirst").change(function () {
alert($(this.find('option:selected')).text());<-- **trouble line**
});
thanks
To get the value...
$(".js-CellFirst").val();
To get the text of the selected option
element.
$(".js-CellFirst option:selected").text();
However, your specific issue is with your parenthesis, of which you have nested correctly. The correct use is...
alert($(this).find('option:selected').text());
Get selected value of a dropdown's item using jQuery
Just use alert($(this).val();
instead:
$(".js-CellFirst").change(function () {
alert($(this).val());
});