Mar*_*vzz 3 html javascript jquery
<select id="my-select">
<option value="1">This is one</option>
<option value="2" selected>This is two</option>
...
</select>
Run Code Online (Sandbox Code Playgroud)
有没有办法获取所选选项的文本值?
$('#my-select').val();
Run Code Online (Sandbox Code Playgroud)
给了我2,我想得到这是两个.
怎么样?
rah*_*hul 10
你想要的是什么
.text()在选择器上使用.
$('#my-select option:selected').text();
Run Code Online (Sandbox Code Playgroud)查看工作演示