jQuery get the value from selectbox by its text
This question already has an answer here:
Try using .text() on the selected option. eg:
$('select option:selected').text();
Using filter
method (exact match):
$('select option').filter(function(){
return $(this).text() === '4 Years';
}).val();
Using :contains
selector:
$('select option:contains(4 Years)').val();
If you want the value of the selected option:
$('#year').val();
If you want a specific option by its text:
$("#year option:contains('4 Years')").val();
Regards.
链接地址: http://www.djcxy.com/p/29288.html上一篇: 获取选择标记jQuery的值