单选框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事件)的更多相关文章

  1. Android 广播大全 Intent Action 事件详解

    Android 广播大全 Intent Action 事件详解 投稿:mrr 字体:[增加 减小] 类型:转载 时间:2015-10-20我要评论 这篇文章主要给大家介绍Android 广播大全 In ...

  2. DOM——事件详解

    事件 事件:触发-响应机制 事件三要素 事件源:触发(被)事件的元素 事件名称: click 点击事件 事件处理程序:事件触发后要执行的代码(函数形式) 事件的基本使用  var box = docu ...

  3. JavaScript事件详解-Zepto的事件实现(二)【新增fastclick阅读笔记】

    正文 作者打字速度实在不咋地,源码部分就用图片代替了,都是截图,本文讲解的Zepto版本是1.2.0,在该版本中的event模块与1.1.6基本一致.此文的fastclick理解上在看过博客园各个大神 ...

  4. JavaScript事件详解-zepto的事件实现

    zepto的event 可以结合上一篇JavaScript事件详解-原生事件基础(一)综合考虑源码暂且不表,github里还有中文网站都能下到最新版的zepto.整个event模块不长,274行,我们 ...

  5. 【转载】C# 中的委托和事件(详解:简单易懂的讲解)

    本文转载自http://www.cnblogs.com/SkySoot/archive/2012/04/05/2433639.html C# 中的委托和事件(详解) C# 中的委托和事件 委托和事件在 ...

  6. 用css实现html中单选框样式改变

     我们都知道,input的单选框是一个小圆框,不能直接更改样式.但是我们在很多网页中看到的单选框样式可不仅限于默认的那个样式(看上去没啥新意,也比较丑).那么,接下来我将介绍下如何实现该功能. 首先, ...

  7. SQL Server 默认跟踪(Trace)捕获事件详解

    SQL Server 默认跟踪 -- 捕获事件详解 哪些具体事件默认跟踪文件能够捕获到? --returns full list of events SELECT * FROM sys.trace_e ...

  8. react第五单元(事件系统-原生事件-react中的合成事件-详解事件的冒泡和捕获机制)

    第五单元(事件系统-原生事件-react中的合成事件-详解事件的冒泡和捕获机制) 课程目标 深入理解和掌握事件的冒泡及捕获机制 理解react中的合成事件的本质 在react组件中合理的使用原生事件 ...

  9. JavaScript事件详解-jQuery的事件实现(三)

    正文 本文所涉及到的jQuery版本是3.1.1,可以在压缩包中找到event模块.该篇算是阅读笔记,jQuery代码太长.... Dean Edward的addEvent.js 相对于zepto的e ...

随机推荐

  1. js14--原型2

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  2. [51Nod]NOIP2018提高组省一冲奖班模测训练(一)题解

    http://www.51nod.com/contest/problemList.html#!contestId=72&randomCode=147206 原题水题大赛.. A.珂朵莉的旅行 ...

  3. Stack switching mechanism in a computer system

    A method and mechanism for performing an unconditional stack switch in a processor. A processor incl ...

  4. Vijos——T1279 Leave-绿光

    https://vijos.org/p/1279 背景 期待这一份幸运,和一份冲劲,多么奇妙的际遇…….燕姿在演唱完绿光这首歌后,出给了姿迷一个考题. 北欧有一个传说!人一生中能看见绿光!他就一生都可 ...

  5. 洛谷 P3817 小A的糖果

    P3817 小A的糖果 题目描述 小A有N个糖果盒,第i个盒中有a[i]颗糖果. 小A每次可以从其中一盒糖果中吃掉一颗,他想知道,要让任意两个相邻的盒子中加起来都只有x颗或以下的糖果,至少得吃掉几颗糖 ...

  6. 27. Spring Boot 部署与服务配置

    转自“https://www.cnblogs.com/zhchoutai/p/7127598.html” Spring Boot 其默认是集成web容器的,启动方式由像普通Java程序一样,main函 ...

  7. RGB颜色转换为多种颜色工具、公式

    http://www.easyrgb.com/index.php?X=CALC#Result http://www.easyrgb.com/index.php?X=MATH  

  8. 【iOS开发系列】颜色渐变

    记录: //Transparent Gradient Layer - (void) insertTransparentGradient { UIColor *colorOne = [UIColor c ...

  9. Cocos2d-x学习笔记(一)HelloWorld

    原创文章,转载请注明出处:http://blog.csdn.net/sfh366958228/article/details/38656755 前言 正式来公司实习已有一月,前一月主要是看了<C ...

  10. 计算机系统—CPU结构和内部工作

    一.计算机系统硬件组成 计算机系统的基本组成由:计算器.控制器.存储器.输入和输出设备这5大核心部件组成. 运算器和控制器等继承在一起成为CPU.以下通过这张图能够非常清楚的表达计算机系统.先从全局上 ...