select选中事件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript">
function showMessage()
{
if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==1)
{
alert("你好,你选择了第 1 个");
document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
}
else if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==2)
{
alert("你好,你选择了第 2 个");
document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
}
else if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==3)
{
alert("你好,你选择了第 3 个");
document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
}
else if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==4)
{
alert("你好,你选择了第 4 个");
document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<select id="selectID" onchange="return showMessage()">
<option value="0">-----请选择----</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<div id="divMessage"></div>
</body>
</html>
无标题页
-----请选择----
1
2
3
4
select选中事件的更多相关文章
- jquery事件之select选中事件
根据select下拉列表选中的不同选项执行不同的方法,工作中经常会用到,这里就要用到Jquery的select选中事件 这里给select加一个叫label_id的id,然后通过id选择器找到这个节点 ...
- 使用layui的form.on绑定select选中事件, form.on()不执行的原因分析
使用layui的form.on绑定select选中事件中, form.on()不执行, 主要原因有 1, select标签中没有写lay_filter属性,用来监听 <select id=&qu ...
- 用jquery给select加选中事件
select在前端开发过程中很常用,现在我们要实现一个效果,那就是选中select中的某一项,执行事件,本来自己没怎么接触过这些,最后网上找了一些资料,自己研究了一下,把方法分享给大家,大家如果有需要 ...
- jQuery获取Select选中的Text和Value
获取Select选中的Text和Value语法解释:$("#select_id").change(function(){//code...}); // 为Select添加事件, ...
- Jquery常用radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关设置
获取一组radio被选中项的值:var item = $('input[name=items][checked]').val(); 获取select被选中项的文本:var item = $(" ...
- js获取select改变事件
js获取select改变事件onchage前的值 和 onclick事件 <select id="wupin_id" name="wupin_id" on ...
- jQuery获取Select选中的Text和Value,根据Value值动态添加属性
语法解释:1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发2. var chec ...
- jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中
jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...}); //为Se ...
- jQuery获取Select选中的Text和Value,根据Value值动态添加属性等
语法解释:1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发2. var ch ...
随机推荐
- window8服务器
安装PHP集成环境:XAMPP cmd下查看端口号: 如果直接输入netstat -nao 报不是内部指令的处理方法: c:\WINDOWS\system32\netstat -nao 就可以了. w ...
- kernel build command
Uboot: make ARCH=arm CROSS_COMPILE=${CC} distclean make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_defc ...
- TClientDataSet的FileName属性
读取cds文件数据. FileName一定要在设计时输入,否则程序运行时,不会自动读取cds文件. 因为FORM创建时,数据集组件也相应创建,如果是在运行时 设置FileName,那么是在数据集组件创 ...
- EhLib 的 DbgridEh 影响 其他数据集的Open方法
DbgridEh 对应数据集ADOTable1,其中有个字段 部门编码,另外增加查找字段比如 部门名称 ADOTable2对应查找数据集,包含 部门编码和 部门名称字段. ADOTable1 打开后, ...
- C语言基础:结构体 分类: iOS学习 c语言基础 2015-06-10 21:47 28人阅读 评论(0) 收藏
结构体:是一种用户自定义的数据类型 结构体定义 struct 结构体名 { 成员类型1 成员变量名1; 成员类型2 成员变量名2; -. }; typedef 原类型 ...
- 如何查看linux命令行操作的历史记录-linux
前言 由于刚开始学习linux,对命令行不熟悉,可以查看使用过的命令行历史记录,熟悉命令行并熟练操作,对命令行进行深入地理解. 系统环境 OS:ubuntu16.04. 操作过程 在主文件夹目录即ho ...
- 如何查看Window10系统隐藏文件夹
1 . 打开我的电脑(此电脑)等等诸如此类的称呼 2 . 点击左上角的查看选项 3 . 选中“隐藏的选项” 4 . 完成
- pylot压力测试工具
博客搬家了,欢迎大家关注,https://bobjin.com 由于版本的兼容性问题,现在在windows下搭建pylot+matplotlib压力测试环境真的会令人吃尽苦头.这是因为,pylot从2 ...
- (转)C语言中scanf函数与空格回车
来源:http://blog.csdn.net/xia7139/article/details/14522493
- vue组件独享守卫钩子函数参数详解(beforeRouteEnter、beforeRouteUpdate、beforeRouteLeave)
一样的和前面路由钩子类似的步骤 首先在demo下面的components下面新建一个test.vue组件 test组件代码 <template> <div class="t ...