单选框radio改变事件详解(用的jquery的radio的change事件)
单选框radio改变事件详解(用的jquery的radio的change事件)
一、总结
1、用的jquery的radio的change事件:当元素的值发生改变时,会发生 change 事件,radio选择不同选项的时候恰巧是值发生改变。
二、单选框radio改变事件详解
<input type="radio" name="bedStatus" id="allot" checked="checked" value="allot">Allot
<input type="radio" name="bedStatus" id="transfer" value="transfer">Transfer
$(document).ready(function() {
$('input[type=radio][name=bedStatus]').change(function() {
if (this.value == 'allot') {
alert("Allot Thai Gayo Bhai");
}
else if (this.value == 'transfer') {
alert("Transfer Thai Gayo");
}
});
});
三、单选框选择不同的选项登录的账号密码自动改变


<form class="am-form tpl-form-line-form" action="" method="post">
<div class="am-form-group">
<label class="am-radio-inline tpl-login-remember-me">
<input class="tpl-form-input" type="radio" name="status" id="student" value="0" checked="checked">Student
</label>
<label class="am-radio-inline tpl-login-remember-me">
<input class="tpl-form-input" type="radio" name="status" id=teacher value="1" >Teacher
</label>
</div>
<div class="am-form-group">
<input type="text" class="tpl-form-input" id="username" name="username" required="" value="" placeholder="username">
</div>
<div class="am-form-group">
<input type="password" class="tpl-form-input" id="password" name="password" required="" value="" placeholder="password">
</div>
<!-- 验证码 -->
<!-- <div class="am-form-group">
<input type="text" class="tpl-form-input" id="user-name" name="code" placeholder="CAPTCHA">
</div>
<div class="am-form-group">
<img width="100%" style="cursor: pointer" src="{:captcha_src()}" alt="captcha" onclick="this.src='{:captcha_src()}?'+Math.random();" />
</div> -->
<!--End 验证码 -->
<div class="am-form-group tpl-login-remember-me">
<input id="remember-me" type="checkbox">
<label for="remember-me">
记住密码
</label>
<label style="margin-left: 15px">
<a href="{:url('login/register')}"> 注册</a>
</label>
</div>
<div class="am-form-group">
<button type="submit" class="am-btn am-btn-primary am-btn-block tpl-btn-bg-color-success tpl-login-btn">提交</button>
</div>
</form>
js
<script>
$(document).ready(function() {
$('input[type=radio][name=status]').change(function() {
if (this.value == '0') {
$("#username").val("student");
$("#password").val("student");
}
else if (this.value == '1') {
$("#username").val("teacher");
$("#password").val("teacher");
}
});
});
</script>
单选框radio改变事件详解(用的jquery的radio的change事件)的更多相关文章
- Android 广播大全 Intent Action 事件详解
Android 广播大全 Intent Action 事件详解 投稿:mrr 字体:[增加 减小] 类型:转载 时间:2015-10-20我要评论 这篇文章主要给大家介绍Android 广播大全 In ...
- DOM——事件详解
事件 事件:触发-响应机制 事件三要素 事件源:触发(被)事件的元素 事件名称: click 点击事件 事件处理程序:事件触发后要执行的代码(函数形式) 事件的基本使用 var box = docu ...
- JavaScript事件详解-Zepto的事件实现(二)【新增fastclick阅读笔记】
正文 作者打字速度实在不咋地,源码部分就用图片代替了,都是截图,本文讲解的Zepto版本是1.2.0,在该版本中的event模块与1.1.6基本一致.此文的fastclick理解上在看过博客园各个大神 ...
- JavaScript事件详解-zepto的事件实现
zepto的event 可以结合上一篇JavaScript事件详解-原生事件基础(一)综合考虑源码暂且不表,github里还有中文网站都能下到最新版的zepto.整个event模块不长,274行,我们 ...
- 【转载】C# 中的委托和事件(详解:简单易懂的讲解)
本文转载自http://www.cnblogs.com/SkySoot/archive/2012/04/05/2433639.html C# 中的委托和事件(详解) C# 中的委托和事件 委托和事件在 ...
- 用css实现html中单选框样式改变
我们都知道,input的单选框是一个小圆框,不能直接更改样式.但是我们在很多网页中看到的单选框样式可不仅限于默认的那个样式(看上去没啥新意,也比较丑).那么,接下来我将介绍下如何实现该功能. 首先, ...
- SQL Server 默认跟踪(Trace)捕获事件详解
SQL Server 默认跟踪 -- 捕获事件详解 哪些具体事件默认跟踪文件能够捕获到? --returns full list of events SELECT * FROM sys.trace_e ...
- react第五单元(事件系统-原生事件-react中的合成事件-详解事件的冒泡和捕获机制)
第五单元(事件系统-原生事件-react中的合成事件-详解事件的冒泡和捕获机制) 课程目标 深入理解和掌握事件的冒泡及捕获机制 理解react中的合成事件的本质 在react组件中合理的使用原生事件 ...
- JavaScript事件详解-jQuery的事件实现(三)
正文 本文所涉及到的jQuery版本是3.1.1,可以在压缩包中找到event模块.该篇算是阅读笔记,jQuery代码太长.... Dean Edward的addEvent.js 相对于zepto的e ...
随机推荐
- 关于我遇到的“LNK 2019无法解析的外部符号”的链接错误
昨天在调试程序的时候出现了"LNK 2019无法解析的外部符号"的问题(VS2008),依照网上说的方法都没有解决这个问题,最后在项目文件里发现有两个同名的可是不在同一个目录下的c ...
- WINDOWS8.1企业版官方下载
这是评估版 WINDOWS8.1企业版官方下载源 https://www.itechtics.com/download-windows-8-1-enterprise-offline-installer ...
- Android控件开发之Gallery3D效果
package xiaosi.GalleryFlow; import android.app.Activity; import android.os.Bundle; public class Gall ...
- Flume的可管理性
Flume的可管理性 所有agent和Collector由master统一管理,这使得系统便于维护. 多master情况,Flume利用 ZooKeeper和gossip,保证动态配置数据的一致性. ...
- SUSE Linux Enterprise Server 11 64T 安装(带清晰视频)
SUSE Linux Enterprise Server 11 64T 安装实录 650) this.width=650;" onclick='window.open("http: ...
- ORA-16047: DGID mismatch between destination setting and standby
主库有报错如下: ORA-16047: DGID mismatch between destination setting and standby 原因:主库参数设置错误,检查下列参数:log_arc ...
- BZOJ2527: [Poi2011]Meteors(整体二分)
Description Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby gala ...
- SpringBoot进阶教程 | 第四篇:整合Mybatis实现多数据源
这篇文章主要介绍,通过Spring Boot整合Mybatis后如何实现在一个工程中实现多数据源.同时可实现读写分离. 准备工作 环境: windows jdk 8 maven 3.0 IDEA 创建 ...
- 【例题 8-1 UVA 120 】Stacks of Flapjacks
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 从大到小安排. 显然想让第i大的数字归位 只要让他翻到最上面,然后再翻回来就ok了 即operate(pos[i]) -> o ...
- GIS学习 Geoserver使用添加、删除、查询地图中的POI
geoserverwfs:Querywfs:Deletewfs:Updatewfs:Insert 在geoserver自定义的地图中通过geoserver wfs 查询,删除,添加相关的POI. 相 ...