zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    xgzc— math 专题训练(一)
    floyd判圈算法
    CF961G Partitions
    luoguP4778 Counting swaps
    AT3913 XOR Tree(巧妙转换+状压dp)
    手动实现aop编程
    代理模式
    spring重点一:处理对象创建时间 个数以及方式
    spring helloword
    spring用来干什么,解决的问题
  • 原文地址:https://www.cnblogs.com/phpfans2012/p/4001322.html
Copyright © 2011-2022 走看看