select的option触发事件
<!DOCTYPE html>
<html lang="zh"> <head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style type="text/css">
.option_show {
display: none;
} .discount {
width: 70px;
}
</style>
</head> <body>
<select class="select" name="oyhfd">
<option value="0" selected="selected">请选择</option>
<option class="option" value="1">足球</option>
<option class="option" value="2">篮球</option>
<option class="option" value="3">乒乓球</option>
<option class="option" value="4">网球</option>
</select>
<span style="display:none;" class="option_show">
<input type="text" class="discount" id="" name="" placeholder="其他球类"/>
</span>
</body> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
$(".select").on("change", function() {
if($("option:selected", this).val() == 4) {
$(".option_show").show();
} else {
$(".discount").val("");
$(".option_show").hide();
}
});
</script> </html>
select的option触发事件的更多相关文章
- javaScript 的option触发事件
先说jquery的option触发事件,很方便 $("option:selected")//这样就能直接触发选择的option了 在JavaScript中就显得比较麻烦,其实< ...
- option触发事件两种方法总结
代码如下: <!doctype html> <html> <head> <meta charset="UTF-8"> <tit ...
- option触发及获取当前选中的option值
#标签 #<select id="city" class="select"> #JavaScript #$("#city").c ...
- 实现 select中指定option选中触发事件
我们在用到下拉列表框select时,需要对选中的<option>选项触发事件,其实<option>本身没有触发事件方法,我们只有在select里的onchange方法里触发. ...
- select选择option时触发的click事件google不兼容问题
原先的方式,下面代码编写的问题在google浏览器下是触发不了click事件的,具体缘由不清楚,反正都可以概括为不兼容了 碰到问题时,百度到的一篇解决:http://blog.163.com/rihu ...
- select中option的onclick事件失效
html: <select id="pageSelect"> <option value="1" selected onclick=" ...
- select列表遍历和触发事件
1.以下两种都是jquery获取select列表被选中的value.var strText=$("#select_id").find("option:selected&q ...
- 通过jquery触发select自身的change事件
###通过jquery触发select自身的change事件 1.通过js来去触发select的change事件 代码如下:包含了html部分和js部分 //html部分 <select cla ...
- 关于select下拉框选择触发事件
最开始使用onclick设置下拉框触发事件发现会有一些问题: <select> <option value="0" onclick="func0()&q ...
随机推荐
- 洛谷 P1640 BZOJ 1854 [SCOI2010]连续攻击游戏
题目描述 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当他使用某种装备时,他只能使用该装备的某一个属性.并且每种装备 ...
- 【ACM】hdu_zs2_1006_Problem F_201308031058
Problem F Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Subm ...
- asp.net--ado.net5大对象代码示例
连接数据库 string conn_string ="Data Source=localhost;Initial Catalog=SQLtest;Integrated Security=Tr ...
- Spring Boot奇怪的问题:The Bean Validation API is on the classpath but no implementation could be found
注意:此方法不能解决在项目上用了Hibernate Validator的问题. 错误如下: *************************** APPLICATION FAILED TO STAR ...
- 全栈JavaScript之路( 二十 )HTML5 插入 html标记 ( 二 )insertAdjacentHTML
insertAdjacentHTML(), 这种方法也是在IE中最早出现的.如今已纳入html5规范,它接受两个參数,一个是下列的标记之中的一个,一个是要写入的 html 代码文本. beforeb ...
- Fitnesse FIT的使用
FIT是fitnesse使用的默认的引擎(SLIM的使用在上一篇文章中说明),不需要特别声明即可使用执行表格测试,所有编写的fixture都需要继承Fit的Fitxture 编写测试用例前需要先声明c ...
- luogu4012 深海机器人问题 网络流
关键词:最小费用最大流 题目大意:海底是个网格,每个网格边有一定价值的海底化石.每个路线可经过无限个机器人,但上面的化石只能采一次.机器人可沿网格边向东或向北移动.给定机器人起点和终点位置及所能容纳的 ...
- [转载]RouteOS安装设置
原文地址:RouteOS安装设置作者:抟鹏追梦 RouteOS2.7.4可以将一台普通的PC机变成一台专业的路由器,高到ISP的核心路器/认证网关-因为它功能强大稳定,低到家庭网关防火墙-因为它免费. ...
- Android应用优化之代码检测优化
在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...
- window下安装git