介绍了jQuery对Select的操作进行了详细的汇总。

1.jQuery添加/删除Select的Option项:
2.$("#select_id").append("<option value='Value'>Text</option>");   //为Select追加一个Option(下拉项)  
3.$("#select_id").prepend("<option value='0'>请选择</option>");   //为Select插入一个Option(第一个位置)  
4.$("#select_id option:last").remove();   //删除Select中索引值最大Option(最后一个)  
5.$("#select_id option[index='0']").remove();   //删除Select中索引值为0的Option(第一个)  
6.$("#select_id option[value='3']").remove();   //删除Select中Value='3'的Option  
7.$("#select_id option[text='4']").remove();   //删除Select中Text='4'的Option  
8.$("#select_id").empty(); //清空select中的option

1.jQuery获取Select选择的Text和Value:
2.$("#select_id").change(function(){//code...});    //为Select添加事件,当选择其中一项时触发  
3.var checkText=$("#select_id").find("option:selected").text();   //获取Select选择的Text  
4.var checkValue=$("#select_id").val();   //获取Select选择的Value  www.jbxue.com
5.var checkIndex=$("#select_id ").get(0).selectedIndex;   //获取Select选择的索引值 
6.var maxIndex=$("#select_id option:last").attr("index");   //获取Select最大的索引值 jQuery设置Select选择的Text和Value:

jQuery对Select操作大集合的更多相关文章

  1. jQuery Select操作大集合

    jQuery获取Select选择的Text和Value: 语法解释:  $("#select_id").change(function(){//code...});    //为S ...

  2. JQuery的Select操作集合

    jQuery获取Select选择的Text和Value:   语法解释: $("#select_id").change(function(){//code...}); //为Sel ...

  3. jQuery对select操作小结

    //遍历option和添加.移除optionfunction changeShipMethod(shipping){ var len = $("select[@name=ISHIPTYPE] ...

  4. jQuery对select操作

    (转自:http://www.cnblogs.com/as285996985/articles/1535014.html) //遍历option和添加.移除optionfunction changeS ...

  5. js 数组操作大集合

    js数组的操作 用 js有非常久了,但都没有深究过js的数组形式.偶尔用用也就是简单的string.split(char).这段时间做的一个项目.用到数组的地方非常多.自以为js高手的自己竟然无从下手 ...

  6. Java 文件操作大集合

    package com.sess.hny.sys.fileserver; import java.io.BufferedInputStream;import java.io.BufferedOutpu ...

  7. Jquery对select的操作(附日历天数变化代码)

    转载请注明出处. 逃不开传统的四种操作:增.删.改.查. <四处搜刮了jquery对select操作的代码,汇集一下,方便以后查看.日历天数变化代码为原创.> [增]: $("# ...

  8. JAVA大集合数据分批次进行切割处理

    今天遇到一个大集合里面的数据删除问题, 因为是一个大集合,如果同时传递到数据库,那么就会造成数据库压力 所以分批次的进行批量操作 其实 也可以采用多线程来处理或者多批次加多线程来处理都是可以的 下面的 ...

  9. jQuery对下拉框Select操作总结

    jQuery对下拉框Select操作总结 转自网络,留做备用 jQuery获取Select元素,并选择的Text和Value: 1. $("#select_id").change( ...

随机推荐

  1. WPF 之 跳转

    WPF的跳转有两种:一是windows窗体,另外一种是page页. 1.windows窗体跳转 1)先实例化目标窗体: 2)然后将目标窗体show(). 例如:有两个窗体Main和Login,要想点击 ...

  2. velocity 随笔

    资源网站: http://wiki.apache.org/velocity/ http://velocity.apache.org/engine/releases/velocity-1.7/user- ...

  3. java 输入输出 io

    学习JAVA  输入输出篇 java不像C中拥有scanf这样功能强大的函数,大多是通过定义输入输出流对象.常用的类有BufferedReader,Scanner.实例程序:一,利用 Scanner ...

  4. Vmware出现报错The VMware Authorization Service is not running.之后无法上网解决

    今天一大早开VMware,启动ubuntu时出现了报错The VMware Authorization Service is not running,服务Authorization没有运行. 这之前一 ...

  5. Ubuntu15.10使用mysql

    安装 sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install libmysql ...

  6. poj 2455 Secret Milking Machine 二分+最大流 sap

    题目:p条路,连接n个节点,现在需要从节点1到节点n,不重复走过一条路且走t次,最小化这t次中连接两个节点最长的那条路的值. 分析:二分答案,对于<=二分的值的边建边,跑一次最大流即可. #in ...

  7. 转: ffmpeg 的deom列表

    http://blog.csdn.net/leixiaohua1020/article/details/47072861

  8. ASP.NET多线程下使用HttpContext.Current

    本来要实现asp.net下使用tcp通讯方式向服务器获取数据,开始采用的方式是 参考: ASP.NET多线程下使用HttpContext.Current为null解决方案 http://www.cnb ...

  9. Person

    using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace PersonD ...

  10. CSS - 实现文字显示过长时用省略

    一.添加-文字显示超出范围时隐藏属性 overflow:hidden; 二.添加-超出文字省略号属性 text-overflow:ellipsis; 三.添加-文字不换行属性 white-space: ...