jQuery获取Select选择的Text和Value:

      1. var checkText=jQuery("#select_id").find("option:selected").text();   //获取Select选择的Text

      2. var checkValue=jQuery("#select_id").val();   //获取Select选择的option Value

      3. var checkIndex=jQuery("#select_id ").get(0).selectedIndex;   //获取Select选择的索引值

      4. var maxIndex=jQuery("#select_id option:last").attr("index");   //获取Select最大的索引值

jQuery添加/删除Select的Option项:

      1. jQuery("#select_id").append("<option value='Value'>Text</option>");   //为Select追加一个Option(下拉项)

      2. jQuery("#select_id").prepend("<option value='0'>请选择</option>");   //为Select插入一个Option(第一个位置)

      3. jQuery("#select_id option:last").remove();   //删除Select中索引值最大Option(最后一个)

      4. jQuery("#select_id option[index='0']").remove();   //删除Select中索引值为0的Option(第一个)

      5. jQuery("#select_id option[value='3']").remove();   //删除Select中Value='3'的Option

      6. jQuery("#select_id option[text='4']").remove();   //删除Select中Text='4'的Option

内容清空:

      jQuery("#select_id").empty();

jQuery关于Select的操作的更多相关文章

  1. 【jq】JQuery对select的操作

    下拉框 <select id="selectID" name="selectName"> <option vlaue="1" ...

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

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

  3. jQuery的select相关操作

    例: <select class="selector" id="selector"></select> 1.设置value为pxx的项选 ...

  4. jQuery select的操作代码

    jQuery對select的操作的实际应用代码. //改變時的事件  复制代码代码如下: $("#testSelect").change(function(){ //事件發生  j ...

  5. jQuery对Select操作大集合

    介绍了jQuery对Select的操作进行了详细的汇总. 1.jQuery添加/删除Select的Option项: 2.$("#select_id").append("& ...

  6. JQuery 对 Select option 的操作---转载

    <select id="selectID" > <option value="1">1</option> <optio ...

  7. jquery获得select option的值和对select option的操作

    <body> <select name="month" id="selMonth" onchange="set()"> ...

  8. jquery select 常用操作总结

    由于在项目各种所需,经常碰到select不种操作的要求,今天特意总结了一下,分享: jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id&q ...

  9. jquery获得select option的值 和对select option的操作

    jQuery获取Select元素,并选择的Text和Value: 1. $("#select_id").change(function(){//code...});   //为Se ...

随机推荐

  1. Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use.

    Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use. The ...

  2. POJ 1436 区间染色

    Horizontally Visible Segments Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4507   Ac ...

  3. 无刷新 checkbox列表的删除

    前台 JS : function ModelDelete() { var checkvalues = null; var checValue = $("#dom1").find(& ...

  4. ssh原理

     客户端向服务器端发出连接请求 服务器端向客户端发出自己的公钥 客户端使用服务器端的公钥加密通讯密钥然后发给服务器端 如果通讯过程被截获,由于窃听者即使获知公钥和经过公钥加密的内容,但不拥有私 ...

  5. Android Studio如何发布APK

    (1)Android Studio菜单Build->Generate Signed APK (2)弹出窗口 (3)创建密钥库及密钥,创建后会自动选择刚创建的密钥库和密钥(已拥有密钥库跳过)    ...

  6. 用Unity实现的依赖注入

    第一步:添加引用 上面那两个玩意 第二步:在app_start中添加unityconfig 上面那个玩意 第三步:在global.asax文件中进行初始化 如上面的,在application_star ...

  7. jQuery 中 children() 与 find() 用法的区别

    1.children() 与 find() 用法的区别 通过children获取的是该元素的下级元素,而通过find获取的是该元素的下级所有元素.

  8. 数组prototype添加函数呢,采用回调判定函数内容

    1.解决方案 Array.prototype.all = function (p) { return this.filter(p).length == this.length; }; Array.pr ...

  9. Be Careful With BuildConfig.DEBUG

    Be Careful With BuildConfig.DEBUG http://www.digipom.com/be-careful-with-buildconfig-debug/

  10. hdu 2028

    PS:以前对long long型的数据就一直不怎么明白...弄了好久... long long a; scanf("%lld",&a); printf("%lld ...