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 ...
随机推荐
- docker小demo
http://www.blogjava.net/yongboy/archive/2013/12/12/407498.html
- html头标签meta实现refresh重定向
<html> <head> <meta http-equiv="content-type" content="text/html; char ...
- centos下tomcat启动卡死
遇到好几次了,总是忘记哪个位置~!!! tomcat启动时查看日志会卡在一个位置很长时间,如下 28-Aug-2018 22:56:55.216 INFO [localhost-startStop-1 ...
- Excel 设置标题栏
1. 选中列表标题行, 可以设置字体居中显示,并放大字体以表示这是标题栏. 2. 选中列表第一数据行,即列表标题行下一行,选择View > Freeze Panes.
- Linux Foundation(笔记)
/************************************************************* * Linux Foundation * 1. 总结一下Linux的基础内 ...
- C#Delegate.Invoke、Delegate.BeginInvoke And Control.Invoke、Control.BeginInvoke
作者:EasonLeung 一.Delegate的Invoke.BeginInvoke 1.Delegate.Invoke (委托同步调用) a.委托的Invoke方法,在当前线程中执行委托. b.委 ...
- android中的两种上下文区别
1.this 继承于content 子类 2.getAppliCationContext() 返回值为context 父类 父类有的子类都有,子类父类不一定有. 在对话框 ...
- 在 Windows 10 中开启移动 WLAN 热点
本文将介绍如何在 Windows 10 中开启移动 Wi-Fi 热点. This post is written in multiple languages. Please select yours: ...
- dfs、遍历与for
dfs实际上就是若干个递归式连续使用,从而把所有情况全部遍历的方法 首先是递归式的连用,然后注意参数的选取以及变化就行了 1.参数一般有状态参数与开关参数 最简单的dfs就是每次选择只是改变自身状态( ...
- LG3898 [湖南集训]大新闻
题意 题目描述 **记者弄了个大新闻,这个新闻是一个在 [0,n) 内等概率随机选择的整数,记其为 x.为了尽可能消除这个大新闻对公众造成的不良印象,我们需要在 [0,n)内找到某一个整数 y,使得 ...