手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery操作select下拉框的text值和value值的方法
jQuery操作select下拉框的text值和value值的方法
摘要:1、jquery获取当前选中select的text值varcheckText=$("#slc1").find("option:selecte...

1、jquery获取当前选中select的text值

var checkText=$("#slc1").find("option:selected").text();

2、jquery获取当前选中select的value值

var checkValue=$("#slc1").val();

3、jquery获取当前选中select的索引值

var index=$("#slc1 ").get(0).selectedIndex;

4、jquery设置索引值为1的项为当前选中项

$("#slc1 ").get(0).selectedIndex=1;

5、jquery设置value值2的项为当前选中项

$("#slc1 ").val(2);

6、jquery设置text值为"青藤园"的项为当前选中项

$("#slc1 option[text='青园w']").attr("selected",true);

7、为指定select下拉框追加一个option(追加到在末尾)

$("#slc2").append(""+i+"");

8、为制定select下拉框插入一个option(插入到第一个位置)

$("#slc2").prepend("请选择");

9、jquery删除select下拉框的最后一个option

$("#slc2 option:last").remove();

【jQuery操作select下拉框的text值和value值的方法】相关文章:

jQuery仿gmail实现fixed布局的方法

jquery判断至少有一个checkbox被选中的方法

JavaScript实现表格点击排序的方法

jQuery实现不断闪烁文字的方法

JavaScript操作XML文件之XML读取方法

JQuery中DOM事件绑定用法详解

快速判断某个值是否在select中的方法

js验证上传图片的方法

jQuery判断指定id的对象是否存在的方法

jQuery切换所有复选框选中状态的方法

精品推荐
分类导航