function getSelectval(id){
var selId = document.getElementById(id); //获取select的id
var seleIndex =selId.selectedIndex; //获取被选项的引索值
alert(selId.options[seleIndex].value); //获取被选项的value
    alert(selId.options[seleIndex].text); //获取被选项的文本
}

 
<select id="sel" onchange="getSelectval('sel')">
<option selected value="1">val1</option>
<option value="2">val2</option>
<option value="3">val3</option>
</select>

 

select获取到option的value和text方法的更多相关文章

  1. jquery 获取下拉框 某个text='xxx'的option的属性 非选中 如何获得select被选中option的value和text和......

    jquery 获取下拉框 某个text='xxx'的option的属性 非选中 5 jquery 获取下拉框 text='1'的 option 的value 属性值 我写的var t= $(" ...

  2. 如何获得select被选中option的value和text

    如何获得select被选中option的value和text 一:JavaScript原生的方法 1:拿到select对象: var myselect=document.getElementById( ...

  3. 26.如何获得select被选中option的value和text

    如何获得select被选中option的value和text 一:JavaScript原生的方法 1:拿到select对象: var myselect=document.getElementById( ...

  4. 获得select被选中option的value和text

    一:JavaScript原生的方法 1:得到select对象: var myselect=document.getElementById(“test”); 2:得到选中项的索引:var index=m ...

  5. 如何获得select被选中option的value和text和......

    我想获取select选中的value,或者text,或者…… 比如这个: <select id="select"> <option value="A&q ...

  6. 如何获得select被选中option的value和text和其他属性值

    比如这个: <select id="select"> <option value="A" url="http://www.baidu ...

  7. 依然同上~ 点击获取当前option的value与text

    $(".tjbtn").click(function(){ $('#leader').each(function(index, ele){ var leader = ele.val ...

  8. select 获取选中option的值方法,选中option方法

    options=$("#Select option:selected"); options.attr('name');options.val(); options.text(); ...

  9. 改变select组件的option选中状态的快捷方法

    以前我都是在<option>标签处通过判断value是否与其中一个相同然后输出selected="selected"来处理的,今天发现可以直接能过Js改变<sel ...

随机推荐

  1. Git知识点汇总

    设置全局用户名 git config --global user.name "yourname" 设置全局邮箱 git config --global user.email &qu ...

  2. MVC5中的路由

    [Route("dazhao/{id}")] [Route("xixi/index")] [Route("xiaohan")] public ...

  3. ConnectionState详解

    ConnectionState有六个属性值ConnectionState.Broken;与数据源连接断开.只有在连接打开后才有可能发生这种情况.可以关闭处于这种状态下的连接,然后重新打开.Connec ...

  4. C#:数据库通用访问类 SqlHelper

    using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; usin ...

  5. 动态绑数据(GridView控件Header和ItemTemplate)

    想了解此篇文章,建议先预习一下<动态变更GridView控件列名>http://www.cnblogs.com/insus/p/3232057.html,因为多少有些关联.不管怎样,它能够 ...

  6. Binder学习笔记(二)——defaultServiceManager()返回了什么?

    不管是客户端还是服务端,头部都要先调用 sp < IServiceManager > sm = defaultServiceManager(); defaultServiceManager ...

  7. 【转】oracle远程导入数据库

    源地址:http://blog.chinaunix.net/uid-20980141-id-447996.html

  8. SPI 实现原理及运用

    SPI原理 SPI的全名为Service Provider Interface.大多数开发人员可能不熟悉,因为这个是针对厂商或者插件的.在java.util.ServiceLoader的文档里有比较详 ...

  9. react 部分语法补充

    jsx语法 todolist.js import React, { Component,Fragment } from 'react'; import './style.css' class Todo ...

  10. 【STL基础】deque

    deque (double-ended queue) 构造函数: //default: deque<T> d; //空的vector //fill: deque<T> d(n) ...