现在遇到一个问题:jQuery只能获取select标签的第一个值,请问怎么解决这个问题
时间: 2024-05-24 09:14:47 浏览: 144
您可以使用jQuery中的val()函数来获取select标签的选中值。例如,如果您有一个ID为“selectID”的select标签,您可以使用以下代码获取选中值:
var selectedValue = $('#selectID').val();
这将返回选中值的字符串形式。如果您想要获取选中选项的文本,请使用以下代码:
var selectedText = $('#selectID option:selected').text();
希望能够解决您的问题!
阅读全文
相关推荐


















