一、前言 接著上一章選擇器的知識,繼續啊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)