jquery 触发/失去焦点事件例子详解
触发焦点:
$("Element").focus()
触发每一个匹配元素获得焦点事件。
$("Element").focus(function)
事件会在获得焦点的时候触发,既可以是鼠标行为,也可以是按tab键导航触发的行为,并且绑定一个处理方法。
失去焦点:
$("Element").blur()
触发每一个匹配元素失去焦点事件。
$("Element").blur(function)
事件会在元素失去焦点的时候触发,既可以是鼠标行为,也可以是按tab键离开的行为,并且绑定一个处理方法。
例子一
代码如下 复制代码
$(document).ready(function(){
$(".regbox .textb").bind("focus",function(){});
$(".regbox .textb").bind("blur",function(){});
$("input").css({"background-colo(www.111cn.net)r":"#fff3de"});
//if (screen.width>=1280){}else if (screen.width<1280){}
})
例子二
代码如下 复制代码
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#username').focus(function ()//得到教室时触发的时间
{
$('#username').val('');
})
$('#username').blur(function () 失去焦点时触发的时间
{
if ($('#username').val() == 'marry') {
$('#q').text('用户名已存在!')
}
else { $('#q').text('ok!') }
})
from:http://www.111cn.net/wy/jquery/60507.htm
jquery 触发/失去焦点事件例子详解的更多相关文章
- jquery触发/失去焦点事件
触发焦点: $("Element").focus() 触发每一个匹配元素获得焦点事件. $("Element").focus(function) 事件会在获得焦 ...
- jQuery 事件用法详解
jQuery 事件用法详解 目录 简介 实现原理 事件操作 绑定事件 解除事件 触发事件 事件委托 事件操作进阶 阻止默认事件 阻止事件传播 阻止事件向后执行 命名空间 自定义事件 事件队列 jque ...
- 【转】JQuery上传插件Uploadify使用详解及错误处理
转自:http://www.jb51.net/article/43498.htm 关于JQuery上传插件Uploadify使用详解网上一大把,基本上内容都一样.我根据网上的步骤配置完成后,会报一些错 ...
- 委托与事件代码详解与(Object sender,EventArgs e)详解
委托与事件代码详解 using System;using System.Collections.Generic;using System.Text; namespace @Delegate //自定义 ...
- jQuery中getJSON跨域原理详解
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp28 jQuery中getJSON跨域原理详解 前几天我再开发一个叫 河蟹工 ...
- cocos2dx+lua注册事件函数详解 事件
coocs2dx 版本 3.1.1 registerScriptTouchHandler 注册触屏事件 registerScriptTapHandler ...
- cocos2dx+lua注册事件函数详解
coocs2dx 版本 3.1.1 registerScriptTouchHandler 注册触屏事件 registerScriptTapHandler 注册点击事件 registerScriptHa ...
- jQuery Pagination Ajax分页插件中文详解(摘)
jQuery Pagination Ajax分页插件中文详解 by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxin ...
- Lambda表达式详解(例子详解)(转自:http://blog.csdn.net/damon316/article/details/51734661)
Lambda表达式详解(例子详解) lambda简介 lambda运算符:所有的lambda表达式都是用新的lambda运算符 " => ",可以叫他,“转到”或者 ...
随机推荐
- oracle 的分析函数
row_number() over(partition by ... order by ...) rank() over(partition by ... order by ...) dense_ra ...
- ireport5.6+jasperreport6.3开发(一)--中文环境配置在
ireport在pdf的情况下无法显示中文字的解决方法 1,首先下载宋体的ttf(注意ttc的不行)下载链接如下(注意你可以用其他的ttf不一定要宋体) http://files.cnblogs.co ...
- 51nod1265 四点共面
题目链接:51nod 1265 四点共面 四个点构成的三个向量a,b,c共面的充要条件是存在不全为零的实数x,y,z满足x*a+y*b+z*c=0,然后想到线代了.. 其实就是三个向量的混合积为0:( ...
- iPhone 6 Screen Size and Web Design Tips
Apple updated its iPhone a bit ago making the form factor much bigger. The iPhone 6 screen size is b ...
- Amazon评论数据的预处理代码(Positive & Negative)
Amazon评论数据的预处理代码,用于情感分析,代码改自 https://github.com/PaddlePaddle/Paddle/tree/develop/demo/quick_start/da ...
- Java Js实现导出csv
$.ajax({ type: 'GET', async: false, url: '../../api/screening/exportTable?seriesIndex=' + param.seri ...
- 关于display:inline-block和float:left的区别
<div class="pag"> <a href="#">首页</a> <a href="#"& ...
- nodeType的意思
nodeType是用来获得当前节点对象的类型.nodeType 属性可返回节点的类型.元素element 1 属性attr 2 文本text 3 注释comments 8 ...
- [原创]C#应用WindowsApi实现查找\枚举(FindWindow、EnumChildWindows)窗体控件,并发送消息。
首先介绍基本WindowsApi: public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 函 ...
- N 皇后问题
#include <set> #include <iostream> #include <string> #include <vector> #incl ...