JSP页面获取下来框select选中项的值和文本的方法
2014-03-08 16:31
330 查看
<select id="username" name="">
<option value="1">jyy</option>
<option value="2">abc</option>
</select>
code:
一:javascript方法
var mySelect=document.getElementById("username");
var index=myselect.selectedIndex ;
选中项的value: myselect.options[index].value;
选中项的text: myselect.options[index].text;
二:jquery方法(前提是已经加载了jquery库)
var options=$("#test option:selected");
选中项的value:alert(options.val());
选中项的text:alert(options.text());
<option value="1">jyy</option>
<option value="2">abc</option>
</select>
code:
一:javascript方法
var mySelect=document.getElementById("username");
var index=myselect.selectedIndex ;
选中项的value: myselect.options[index].value;
选中项的text: myselect.options[index].text;
二:jquery方法(前提是已经加载了jquery库)
var options=$("#test option:selected");
选中项的value:alert(options.val());
选中项的text:alert(options.text());
相关文章推荐
- jsp页面获取select选择框里面的值的两种方法
- jsp页面获取select选择框里面的值的两种方法
- jquery获取select选中值的文本,并赋值给另一个输入框的方法
- JSP获取上一个访问页面URL的方法
- jquery对select进行种各种操作的方法[联动、根据值或文本选中指定的select等]
- JS获取下拉列表(select)选中项的值和文本
- Strut2 的 Action获取JSP 页面参数的方法
- Javascript获取select的选中值和选中文本
- js获取下拉列表选中项的值和文本(select)以及获取单选按钮(radio)组的值和修改选中项[转]
- JavaScript获取select选中的值和文本
- js获取下拉列表选中项的值和文本(select)以及获取单选按钮(radio)组的值和修改选中项[转]
- Javascript和jquery获取select下拉框选中的的值和文本
- Javascript获取select的选中值和选中文本
- 怎么从JSP页面获取SELECT中value的值
- js和Jquery获取选中select值和文本
- 在JSP页面中获取当前日期时间的方法
- jsp jquery 页面中select显示加载后的数据默认选中项
- jquery获取select选中值的文本,并赋值给另一个输入框
- Javascript获取select的选中值和选中文本
- 在jsp页面中获取图片,css资源的绝对路径方法