Get text of the selected option with jQuery
This question already has an answer here:
关闭,你可以使用
$('#select_2 option:selected').html()
$(document).ready(function() {
$('select#select_2').change(function() {
var selectedText = $(this).find('option:selected').text();
alert(selectedText);
});
});
小提琴
Change your selector to
val = j$("#select_2 option:selected").text();
You're selecting the <select>
instead of the <option>
上一篇: jQuery通过其文本从selectbox中获取值
下一篇: 使用jQuery获取所选选项的文本