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

    事件绑定:
    bind(type[,data],fn);
    第一个参数是事件类型:blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove,
    mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error.当然也可以是自定义名称.
    第二个参数是可选参数:event.data属性值传递给事件对象的额外数据对象.
    第三个参数是用来绑定的处理函数.
    合成事件: hover()方法 toggle()方法
    hover(enter,leave)模拟光标悬停事件,光标移动到元素上时,会触发指定的第一个函数enter,当光标移出这个元素时会触发指定的第二个函数leave
    eg:
    $(funcation(){
        $("#panel").hover(function(){
            $(this).next("div.content").show();
        },function(){
            $(this).next("div.content").hide();
        });
    });
    toggle(f1, f2, f3, .... fn)模拟鼠标连续单击事件
    冒泡事件:
    event.type()方法 获取到事件的类型
    alert(event.type);
    event.preventDefault()方法,阻止默认的事件行为
    event.stopPropagation()方法,阻止事件的冒泡。
    event.target()方法,获取到触发事件的元素。
    alert(event.target.href);
  • 相关阅读:
    JS中的call()和apply()方法和bind()
    reactjs入门到实战(十)----one-first_app
    49-Reverse Linked List II
    48-Merge Sorted Array
    47-Generate Parentheses
    46.Valid Parentheses
    45-Letter Combinations of a Phone Number
    44-Count and Say
    43-Reverse Nodes in k-Group
    42-Remove Nth Node From End of List
  • 原文地址:https://www.cnblogs.com/chenqingwei/p/1761895.html
Copyright © 2011-2022 走看看