<select id="sel" onchange="javascript:getSelect();">
<option value="a">选择</option>
<option value="bdd">be</option>
<option value="c">ce</option>
<option value="d">de</option>
<option value="e">ee</option>
</select>
<script>
function getSelect() {
//得到select下拉列表中option的value
var optionValue = document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].value;
//得到select下拉列表中option的text
var optionText = document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].text;
}
</script> <select id="sele" onchange="javascript:getE();">
<option value="monday">星期一</option>
<option value="tuesday">星期二</option>
<option value="wednesday">星期三</option>
<option value="thursday">星期四</option>
<option value="friday">星期五</option>
</select>
<script>
function getE() {
//我建议这里也像下面一些写,虽然这样写也可以获得数据
var optionsValue = document.getElementById("sele").value;
alert(optionsValue);
var optionsText = document.getElementById("sele").options[document.getElementById("sele").options.selectedIndex].text;
alert(optionsText);
}
</script>

this.options[selectedIndex]的使用的更多相关文章

  1. select options常用操作

    1.判断select选项中 是否存在Value="value"的option元素 function jsSelectIsExitItem(objSelect,objItemValu ...

  2. JS对select动态添加options操作(主流浏览器兼容)

    之前项目中,遇到一个表单提交的页面,里面有多级下拉框联动的复杂逻辑,因此当时在做的过程中也是学到了不少容易出现问题的地方,下面就整理下当时遇到的一些关于下拉框的操作,并指出其中的一些注意点和坑: 有如 ...

  3. Python WebDriver自动化测试

    转载来自: http://www.cnblogs.com/fnng/p/3160606.html Webdriver Selenium 是 ThroughtWorks 一个强大的基于浏览器的开源自动化 ...

  4. javascript学习笔记全记录

          js的初步了解     1.就是用来修改样式的,修改的是行内样式.任何样式都能够修改.     2.css里面怎么写js就怎么写.     3.任何元素都能加事件:事件都要小写 js的三大 ...

  5. AMap行政区查询服务

    AMap.DistrictSearch行政区查询服务插件,提供全国各省.市.县.区的中心点经纬度.行政区边界坐标组.下级行政区等信息.根据行政区边界坐标组可在地图上绘制行政区边界.(本文为原创,并在项 ...

  6. 有关Select option 元素

    动态添加option元素以及option元素被选中方法: function getType() { ); shadowCoverTipAdd("加载中,请稍候.."); $.aja ...

  7. 轻松自动化---selenium-webdriver(python) (十)

    本节重点 处理下拉框 switch_to_alert() accept() 下拉框是我们最常见的一种页面元素,对于一般的元素,我们只需要一次就定位,但下拉框里的内容需要进行两次定位,先定位到下拉框,再 ...

  8. 【代码笔记】iOS-底下滚动,上面标题栏也会跟着变动

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "SVSegmentedCont ...

  9. JS获取select选中的值,所有option值

    <select name="myselect" id="myselect"> <option value="2042"&g ...

随机推荐

  1. winform GDI基础(一)

    1获取画布 (1)从PaintEventArgs类中获取画布 private void Form1_Paint(object sender, PaintEventArgs e) { Graphics ...

  2. c++内联 inline

    内联声明只是建议 ,不一定就会内联. http://www.voidcn.com/blog/u011327981/article/p-5006835.html

  3. 洛谷P4457/loj#2513 [BJOI2018]治疗之雨(高斯消元+概率期望)

    题面 传送门(loj) 传送门(洛谷) 题解 模拟赛的时候只想出了高斯消元然后死活不知道怎么继续--结果正解居然就是高斯消元卡常? 首先有个比较难受的地方是它一个回合可能不止扣一滴血--我们得算出\( ...

  4. linux的理解

    1.用户组 因为linux 是多人多任务系统 所有可能有很多人在主机人作业.比如 有A B C D 4个人 在linux主机上作业, A B C 3个人 在做同一个项目 建了一个文件夹这个文件只能A ...

  5. nginx的配置文件(反向代理和主配置)

    配置文件保存,是为了工作方便.特别是优化好的配置.我们基本可以直接复制粘贴.这样做可以快速的完成手上的工作!! vim nginx.conf user nginx; worker_processes ...

  6. Drop user 报ORA-00600 [KTSSDRP1]

    一客户删除一个数据库用户THH时报错: 说明在获取seg$时没有找到相应的条目,先来解释下这个600错误的参数含义: Arg [a] Tablespace number Arg [b] File nu ...

  7. Javaweb 实现分页功能

    package cn.zr.testpage.entity; public class User { private String name; private int age; private Str ...

  8. 【Leetcode】Largest Rectangle in Histogram

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  9. element el-tree循环遍历树形结构,并动态赋值disabled属性

    凌晨3点,功夫不负有心人,已经累趴,效果终于出来: 贴上代码: <style scoped> .form { width: 50%; } </style> <templa ...

  10. pre 标签 防止 其撑开 div...

    pre 里面 的内容如果不换行,会导致 div 横向 出现 滚动条...加入下列 css可解决! pre{ white-space: pre-wrap; word-wrap: break-word; ...