我们如何在Jquery中写出这个的等价值
document.getElementById( "selectbox").
options[document.getElementById("selectbox").selectedIndex].innerText;
Run Code Online (Sandbox Code Playgroud)
您想要<option>在<select id="selectbox">标签中选择所选内容并获取其文本:
$('#selectbox option:selected').text()
Run Code Online (Sandbox Code Playgroud)
因为选择框不能真正包含什么,但选项,则可以省略部分:
$('#selectbox :selected').text()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
654 次 |
| 最近记录: |