jquery操作select option使用小结
来源:互联网 发布:金石计价软件破解 编辑:程序博客网 时间:2024/06/12 01:22
1、获取选中select的value和text,代码如下:
<select id="mySelect">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
$("#mySelect").val(); //获取选中记录的value值
$("#mySelect option:selected").text(); //获取选中记录的text值
2、运用new Option("文本","值")方法添加选项option :
var obj = document.getElementById("mySelect");
obj.add(new Option("4","4"));
3、删除所有选项option
var obj = document.getElementById("mySelect");
obj.options.length = 0;
4、删除选中选项option:
var obj = document.getElementById("mySelect");
var index = obj.selectedIndex;
obj.options.remove(index);
5、修改选中选项option :
var obj = document.getElementById("mySelect");
var index = obj.selectedIndex;
obj.options[index] = new Option("three",3); //更改对应的值
obj.options[index].selected = true; //保持选中状态
6、删除select :
var obj = document.getElementById("mySelect");
obj.parentNode.removeChild(obj); //移除当前对象
7、select选择的响应事件:
$("#mySelect").change(function(){
//添加所需要执行的操作代码
})
- jquery操作select option使用小结
- jQuery对select操作小结(遍历option,操作option)
- 浅析jQuery对select操作小结(遍历option,操作option)
- 浅析jQuery对select操作小结(遍历option,操作option)
- 小心使用jquery操作select option表单
- jquery select option 操作
- jquery select option 操作
- jquery操作select option
- jquery操作select option
- jquery select option操作
- JQuery操作select中的option
- jquery操作select小结
- jquery操作select小结
- JQuery 对 Select option 的操作
- jquery select option 操作相关知识
- jquery 对select中的option操作
- jquery 操作select控件 遍历option
- Jquery 对select option 的操作
- android clipPath切割画布
- SQL函数学习 配置函数
- Sencha Touch 2 快速入门系列(一)-- 建立第一个Sencha Touch应用
- PHP 笔记
- 16.python的网络编程
- jquery操作select option使用小结
- [技术分享] 20120401,TMG 生成报告,但内容为空
- jQuery 参考手册 - 遍历
- Windows下完成端口移植Linux下的epoll
- jQuery.cookie.js中cookie设置遇到的问题
- AuthTokenCallback: authFailed
- scp rsync wget 限速
- oracle 排序分页 高效sql语句
- linux 文件修改权限