zoukankan      html  css  js  c++  java
  • jQuery事件

     

    1、回顾事件三要素

    1、事件源

    2、事件类型

    3、事件处理程序

    2、Js中this与jquery中this区别

    Js:this.css(“background-color”,“red”)

    Jquery:$(this).css(“background-color”,“red”)

    3、鼠标事件

    1、单击事件

    $("p").click(function(){

    // 动作触发后执行的代码!!

    });

    2、双击事件

    $("p").dblclick(function(){

        $(this).hide();

    })

    3、鼠标进入

    $("#p1").mouseenter(function(){

    alert('您的鼠标移到了 id="p1" 的元素上!');

    });

    $("#p1").mouseover(function(){

    alert('您的鼠标移到了 id="p1" 的元素上!');

    });

     

    4、鼠标离开

    $("#p1").mouseleave(function(){

    alert("再见,您的鼠标离开了该段落。");

    });

    $("#p1").mouseout(function(){

    alert('您的鼠标移到了 id="p1" 的元素上!');

    });

     

    5、获取焦点

    $("input").focus(function(){

    $(this).css("background-color","#cccccc");

    });

    6、失去焦点

    $("input").blur(function(){

    $(this).css("background-color","#ffffff");

    });

    4、键盘事件

    1、键盘按下

    $("input").keydown(function(){

    $(this).css("background-color","#cccccc");

    });

    2、键盘抬起

    $("input").keyup(function(){

    $(this).css("background-color","#ffffff");

    });

    注意:一句代码中,要么全是js要么全是jQuery。

  • 相关阅读:
    vector与iterator的一些用法
    动态规划 hdu 1024
    dfs bfs hdu 1045
    hdu 2795
    poj 2828
    线段树染色
    线段树比大小
    A
    ?线程局部变量
    JRE、JDK、JVM 及 JIT
  • 原文地址:https://www.cnblogs.com/wangxue13/p/13479770.html
Copyright © 2011-2022 走看看