6.1,获取下拉框的值(html标签中没有onchange事件的)

<script language="javascript">

$(document).ready(function() {

//绑定下拉框change事件,当下来框改变时调用 SelectChange()方法

$("#selectID").change(function() { SelectChange(); });

})

function SelectChange() {

//获取下拉框选中项的text属性值

var selectText = $("#selectID").find("option:selected").text();

alert(selectText);

//获取下拉框选中项的value属性值

var selectValue = $("#selectID").val();

alert(selectValue);

//获取下拉框选中项的index属性值

var selectIndex = $("#selectID").get(0).selectedIndex;

alert(selectIndex);

////获取下拉框最大的index属性值

var selectMaxIndex = $("#selectID option:last").attr("index");

alert(selectMaxIndex);

}

<select id="selectID" >

<option value="1">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

</select>

6.2,获取下拉框的值(html标签中有onchange事件的)

<body>

<dl class="global" style="display:block;">

<dt>

<span style="color:#A60015 !important;padding:0 5px;">*</span> 结算方式:</dt>

<dd>

<label for="select">

<select id="key_ESPaymentMethod" name="ESPaymentMethod" onchange="loadSettlementCycle();" allownull="1"

class="inputW130">

<option value="1" selected="selected">固定金额结算</option>

<option value="2">周期结算+金额结算</option>

</select>

</label>

</dd>

</dl>

</body>

</html>

function loadSettlementCycle() {

//获取下拉框选中项的text属性值

var selectText = $("#key_ESPaymentMethod").find("option:selected").text();

alert(selectText);

//获取下拉框选中项的value属性值

var selectValue = $("#key_ESPaymentMethod").val();

alert(selectValue);

//获取下拉框选中项的index属性值

var selectIndex = $("#key_ESPaymentMethod").get(0).selectedIndex;

alert(selectIndex);

////获取下拉框最大的index属性值

var selectMaxIndex = $("#key_ESPaymentMethod option:last").attr("index");

alert(selectMaxIndex);

}

下拉框的change事件的更多相关文章

  1. 商品类型的下拉框绑定一个事件,通过ajax获取属性

    html代码这么写 <!-- 商品属性 --> <table cellspacing="1" cellpadding="3" width=&q ...

  2. Vue 下拉框值变动事件传多个参数

    在使用 Vue 进行开发时,下拉框值变动事件 @change 是很常用的. 其传参一般分为两种方式:默认传参和自定义传参. 默认传参 @change 默认会传选中项标识的参数,在传参处不用定义,在方法 ...

  3. LayUI中select下拉框选中触发事件

    代码: var form = layui.form, layer = layui.layer; // 监听 $(document).ready(function() { // select下拉框选中触 ...

  4. 关于下拉框的onchange事件和onclick选择value值。

    下拉框的onchange事件和onclick,一般最好都选择onchange事件,onclick可能会不兼容有些浏览器. 下面是代码: <!DOCTYPE html><html la ...

  5. select下拉框选择触发事件

    我一直以来都认为,select 下拉框选择对选项 options 使用 onclick 注册事件即可,如下: <select> <option value="0" ...

  6. 点击select下拉框,触发事件

    <div class="controls moneycheck floatleft"> <select class="span12 chosen_cat ...

  7. 关于select下拉框选择触发事件

    最开始使用onclick设置下拉框触发事件发现会有一些问题: <select> <option value="0" onclick="func0()&q ...

  8. 给datagridview的下拉框添加valueChange事件

    修改datagridview的EditMode属性为EdutOnEnter,否则需要点2次以上才出现下拉框 1.给DataGridView添加EditingControlShowing事件: 2.编辑 ...

  9. js设置下拉框选中后change事件无效解决

    下拉框部分代码: <select id="bigType"> <option value="">请选择</option> & ...

随机推荐

  1. 洛谷 [P1119] 灾后重建

    我们发现每次询问都是对于任意两点的,所以这是一道多源最短路径的题,多源最短路径,我们首先想到floyd,因为询问的时间是不降的,所以对于每次询问,我们将还没有进行松弛操作的的点k操作. #includ ...

  2. bzoj 4873: [Shoi2017]寿司餐厅 [最小割]

    4873: [Shoi2017]寿司餐厅 题意:略 唯一会做的... 一眼最小割 就是最大权闭合子图呀 \(s\rightarrow d_{positive} \rightarrow -d_{negt ...

  3. HDU 4315 Climbing the Hill [阶梯Nim]

    传送门 题意: 和上题基本一样:山顶可以有多人,谁先把king放到山顶谁就胜 并不太明白 #include <iostream> #include <cstdio> #incl ...

  4. Codevs 3990 [中国剩余定理]

    模板题 注意如何得到[a,b]区间范围内的解 #include <iostream> #include <cstdio> #include <cstring> #i ...

  5. php+redis 学习 一 连接

    <?php header('content-type:text/html;chaeset=utf-8'); $redis = new Redis(); $redis->connect('1 ...

  6. CentOS 7 搭建基于携程Apollo(阿波罗)配置中心单机模式

    Apollo(阿波罗)是携程框架部门研发的配置管理平台,能够集中化管理应用不同环境.不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限.流程治理等特性.服务端基于Spring Boot ...

  7. 【转】Nginx配置详解

    转自:http://www.cnblogs.com/knowledgesea/p/5175711.html Nginx常用功能 1. Http代理,反向代理:作为web服务器最常用的功能之一,尤其是反 ...

  8. iOS7控制中心会覆盖由下向上的手势

    Expect users to swipe up from the bottom of the screen to reveal Control Center. If iOS determines t ...

  9. VMware Workstation All Key

    官方下载:https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html 懒人打包:链接:https:/ ...

  10. WinForm中使用DDE技术(含源码)

    提起DDE技术,相信很多人不知道是啥东东,尤其是90后的程序员们.不过,有时候这个东西还是有用处的,用一句话可以总结:实现Winform程序间的通信.比如:两个Winform程序A和B需要实现通信,用 ...