【JQuery】事件

一、前言

       接着上一章选择器的知识,继续啊jQuery的学习

二、内容

$(function(){}) 文档初始化加载

event.pageX  相对于文档左边缘的鼠标位置
event.pageY  相对于文档上边缘的鼠标位置
event.preventDefault()  阻止元素发生默认行为  
event.isDefaultPrevented()  指明是否调用了preventDefault() 
event.result 被指定事件处理器返回的最后一个值
event.target 哪个DOM元素触发了该元素
event.timeStamp 该事件发生时的时间
event.type   事件的类型
event.which  按了哪个键或按钮


bind 绑定事件(对当前存在元素)    
     $(selector).bind("event",data,function)


blur 元素失去焦点
     $(selector).blur(function)


change 元素(select,text,textarea)值发生变化
     $(selector).change(function)


click 点击元素
     $(selector).click(function)


dbclick 双击元素
     $(selector).dbclick(function)


delegate 为子元素添加事件,data可选
     $(selector).delegate(childSelector,"event",data,function)


undelegate 删除由delegate()添加的事件
     $(selector).undelegate(selector,"event",)


die 移除通过live()方法向元素添加的事件
     $(selector).die("event",function)


error 元素遇到错误
     $(selector).error(function)


focus 元素获得焦点
     $(selector).focus(function)


keydown 按钮按下过程
     $(selector).keydown(function)


keypress 按钮按下抬起
     $(selector).keypress(function)


keyup 按钮抬起
     $(selector).keyup(function)


live 附加事件,注意与bind的区别
     $(selector).live("event",data,function)


load 加载事件
     $(selector).load(function)


unload 离开页面,只应用于window对象
     $(window).unload(function)


mouseup 鼠标抬起事件
     $(selector).mouseup(function)


mousedown 鼠标按下事件
     $(selector).mousedown(function)


mouseenter 鼠标进入元素事件
     $(selector).ouseenter(function)


mouseleave 鼠标离开被选元素事件
     $(selector).mouseleave(function)


mousemove 鼠标移动事件,慎用,影响性能
     $(selector).mousemove(function)


mouseout 鼠标离开被选元素或其子元素
     $(selector).mouseout(function)


one 为元素绑定只能运行一次的事件
     $(selector).one("event",data,function)


resize 窗口调整大小
     $(selector).resize(function)


scroll 可滚动对象滑动元素
     $(selector).scroll(function)


select 当textarea或文本型的input元素的文本被选择时
     $(selector).select(function)


submit 提交表单
     $(selector).submit(function)


toggle 轮流切换多个事件,
       第一次点击执行第一个function
       第二次点击执行第二个function
       ...
     $(selector).toggle(function1,function2,function3)
       
       切换Hide()和Show()状态
     $(selector).toggle(speed,callback)

       规定是否只显示或只隐藏匹配元素,true显示;false隐藏
     $(selector).toggle(switch)


trigger 触发事件
     $(selector).trigger("event", [param1,param2,...])
     $(selector).trigger(eventObj)


triggerHandler 触发事件,
               不冒泡,
               不触发浏览器事件,
               只影响第一个匹配项
     $(selector).triggerHandler(function1,function2,function3)


unbind 移除绑定事件
     $(selector).unbind("event",function)
     $(selector).unbind(eventObj)
原文地址:https://www.cnblogs.com/lovecsharp094/p/8448706.html