jquery根据text选中option的问题:
网上找了好多,但发现因为jquery版本问题,很多并不能用。
 
最后成功了,写法如下:
 
  $('#shop option:contains(' + value + ')').each(function(){
      if ($(this).text() == value ) {
          $(this).attr('selected', 'selected');
          return false;
      }
      return tru
  });
 
-------------------------------------------------------------------------------------
javascript获取select的value及text:
var  obj=document.getElementById("shop");
拿到选中项的索引:var index=obj.selectedIndex ;       // selectedIndex代表你所选中项的index
拿到选中项options的value:  obj.options[index].value;
拿到选中项options的text:  obj.options[index].text;

关于Select选中问题的更多相关文章

  1. Jquery获取select选中的文本与值

    jquery获取select选择的文本与值获取select :获取select 选中的 text :    $("#ddlregtype").find("option:s ...

  2. jQuery获取Select选中的Text和Value

    获取Select选中的Text和Value语法解释:$("#select_id").change(function(){//code...});   // 为Select添加事件, ...

  3. Jquery常用radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关设置

    获取一组radio被选中项的值:var item = $('input[name=items][checked]').val(); 获取select被选中项的文本:var item = $(" ...

  4. easyui 》 radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中

    获取一组radio被选中项的值var item = $('input[@name=items][@checked]').val();获取select被选中项的文本var item = $(" ...

  5. jquery获取radio和select选中值

    //jquery 获取radio选中值 <input type="radio" name="c_type" value="a" > ...

  6. jQuery获取Select选中的Text和Value,根据Value值动态添加属性

    语法解释:1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发2. var chec ...

  7. jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中

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

  8. jquery获得select选中索引

          select选中索引有好多方式, 这两种方式取不到索引值这两种方式取不到索引值这两种方式取不到索引值这两种方式取不到索引值 $('#someId').find('option:select ...

  9. jquery设置select选中

    /*设置select选中开始*/ var prod_type=$('.prod_type').val(); //alert(prod_type); var select = document.getE ...

  10. jQuery获取Select选中的Text和Value,根据Value值动态添加属性等

    语法解释:1. $("#select_id").change(function(){//code...});   //为Select添加事件,当选择其中一项时触发2. var ch ...

随机推荐

  1. Redis阅读目录

    一.Redis简介 点击链接查看:https://www.cnblogs.com/hwlong/p/9325986.html 二.Redis安装及基本配置 点击链接查看:https://www.cnb ...

  2. Spring_AOP动态代理详解(转)

    在学习Spring的时候,我们知道Spring主要有两大思想,一个是IoC,另一个就是AOP,对于IoC,依赖注入就不用多说了,而对于Spring的核心AOP来说,我们不但要知道怎么通过AOP来满足的 ...

  3. Spring框架的属性注入

    1. 对于类成员变量,常用的注入方式有两种 * 构造函数注入(没有空的构造方法注入) * 属性setter方法注入(有空的构造方法注入) 2. 在Spring框架中提供了前两种的属性注入的方式 1. ...

  4. Html使用Iframe无刷新上传文件,后台接收

    html代码:我是发送请求到teacher_center.aspx,不是到.ashx一般处理程序里,需要加 runat="server",有空我再试试发送请求到 .ashx 里 & ...

  5. DOMNodeInserted监听div内容改变

    $('.cw-icon .ci-count').on('DOMNodeInserted',function(){ $(".settleup-content .cont_loading&quo ...

  6. Bioconductor简介

    Bioconductor简介 2012-10-09 ~ ADMIN 源:Bioconductor: open software development for computational biolog ...

  7. 给自己名字abel.这个好,怎么字母排序都第一

    给自己名字abel.这个好,怎么字母排序都第一

  8. An integration of deep learning and neuroscience

    Recently, I have read a paper about the integration of deep learing and neuroscience, which elaborat ...

  9. Java生成HTML文件

    实例HTML文件<html> <head> <title>###title###</title> <meta http-equiv="C ...

  10. MongoDB操作数据库的几个命令(自己用)

    本文以配置百度的Clouda为源头:http://cloudajs.org/docs 继而安装node.js:http://nodejs.org/download/(直接安装,简单) 和MongoDB ...