<div class="vip_tit">
年度 <select id="year_id"></select>
&nbsp;
月度
<select id="month_id">
<option selected="selected" 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>
<option value="7">7月</option>
<option value="8">8月</option>
<option value="9">9月</option>
<option value="10">10月</option>
<option value="11">11月</option>
<option value="12">12月</option>
</select>
&nbsp;
<input type="button" name="button" value="查询" onclick="search();" />
</div>
    // 原生获取

    // 年份option对象获取。
var y_option = document.getElementById("year_id"); // 月份option对象获取。
var m_option = document.getElementById("month_id"); // 年份文本值
var y_text = y_option.options[y_option.selectedIndex].text; // 年份value值
var y_value = y_option.options[y_option.selectedIndex].value; // 月份文本值
var m_text = m_option.options[m_option.selectedIndex].text; // 月份value值
var m_value = m_option.options[m_option.selectedIndex].value; // jQuery方式获取
var option = $("#city option:selected").val(); // JS方式获取
var option = $(this).children('option:selected').val(); //option触发事件添加。
$("#city").change(function(){
alert("option");
});

option触发及获取当前选中的option值的更多相关文章

  1. jq获取被选中的option的值。jq获取被选中的单选按钮radio的值。

    温故而知新,一起复习下jq的知识点. (1) jq获取被选中的option的值 <select id="select_id"> <option value=&qu ...

  2. js动态获取select选中的option

    最近在写报表管理模块时,需要通过条件去筛选符合条件的数据,筛选条件用的布局有select,input等.在调试的过程中一直获取不到select选中的option.于是就查询些资料,发现用select的 ...

  3. 比较日期大小以及获取select选中的option的value

    原生JavaScript如何获取select选中的value // 1. 拿到select对象 const selectObject = document.getElementById('test') ...

  4. jquery获取select选中的文本值

    误区: 一直以为jquery获取select中option被选中的文本值,是这样写的:   $("#id").text();  //获取所有option的文本值 实际上应该这样: ...

  5. jQuery获取radio选中项的值【转藏】

    <title></title> <script src="js/jquery-1.7.2.min.js"></script> < ...

  6. Jquery获取select选中的option的文本信息

    注意:以下用的$(this)代表当前选中的select框 第一种: $(this).children("option:selec... ...查看全文

  7. 获取select 选中的option中自定义的名称的之

    <select style="width: 220px;height: 20px;margin: 0 0 0 20px;" id="invest_ticket&qu ...

  8. 【vue系列】elementUI 穿梭框右侧获取当前选中项的值的思路

    最近 做了一个需求 在查询结果的表格中,选取(可多选)一些值,获取到保单号后,打开一个elementUI的穿梭框,然后获取到所有业务员,选取一些业务员后,将上一步获取到的保单号传递给业务员. 画个示意 ...

  9. layui时间控件,获取页面选中的时间值。

    先贴上html文档 <div class='layui-form'> <div class="layui-form-item"> <div class ...

随机推荐

  1. java多线程(二)线程的生命周期

    1.   线程生命周期 新建(New).就绪(Runnable).运行(Running).阻塞(Blocked)和死亡(Dead)5种状态. 1.1. 新建 l  new关键字创建了一个线程之后,该线 ...

  2. pauseable 库

    pauseable.js https://www.npmjs.com/package/pauseable Pauseable allows you to pause event emitters, t ...

  3. less 多行溢出显示省略号无效

    .body { font-size:14px; font-weight:400; line-height:22px; /*! autoprefixer: ignore next */ -webkit- ...

  4. Sql server 中将数据行转列列转行(一)

    在做一些数据分析与数据展示时,经常会遇到行转列,列转行的需求,今天就来总结下: 在开始之前,先来创建一个临时表,并且写入一些测试数据: /* 第一步:创建临时表结构 */ CREATE TABLE # ...

  5. DApp是什么,DApp是必然趋势

    DApp是什么,DApp是必然趋势  https://www.jianshu.com/p/dfe3098de0de Thehrdertheluck关注 12018.04.23 11:54:00字数 2 ...

  6. IntelliJ Idea 常用10款插件(提高开发效率)

    出自:https://blog.csdn.net/weixin_41846320/article/details/82697818 插件安装方式: 1.Background Image Plus 这款 ...

  7. AIX日志相关的命令

    常用的命令有: 1.列出简短的出错信息 errpt | more 2.列出所有硬件出错信息 errpt -d H 3.列出所有软件错误信息 errpt -d S 4.列出详细的出错信息 errpt – ...

  8. 有关dfs、bfs解决迷宫问题的个人见解

    可以使用BFS或者DFS方法解决的迷宫问题! 题目如下: kotori在一个n*m迷宫里,迷宫的最外层被岩浆淹没,无法涉足,迷宫内有k个出口.kotori只能上下左右四个方向移动.她想知道有多少出口是 ...

  9. 后端&前端零碎知识点和注意问题

    后端 1. Spring自带的MD5加密工具类 import org.springframework.util.DigestUtils; String md5Password = DigestUtil ...

  10. C++ Primer 第五版示例gcc源码

    官方资源,原封不动的.对应于GCC,因此文件名是以此命名的. 门牌号: https://github.com/ZeroPhong/Learning-Resource/blob/master/GCC_4 ...