Here are some common DOM events
1 Mouser Events
click dbclick mouseenter mouseleave
2 Keyborars Events
keypress keydown keyup
3 Form Events
submit change focus blus
4 Docment/Wiindow Events
laod resize scroll unload
click()
the function is executed when the user clicks on the html element.
eg:
$("p").click(function(){ $(this).hide(); })
dblclick()
the dblclick() method attaches an event handlerfunction to an html element. the function is executed when the user double-clicks on the html element
eg:
$("p").dblclick(function(){ $(this).hide(); })
mouseenter()
the function is executed when the mouse pointer the html element
eg:
$("p").mouseenter(function(){ alert("you entered p"); })
mouseleave()
the function is executed when the mouse pointer leaves the html element
eg:
$("#p").mouseleave(function(){ alert("bye! you now leave p"); })
mousedown()
the function is executed , when the left,middle or right button is pressed down, while the mouse is over the html element
eg:
$("p").mousedown(function(){ alert("mouse down over p"); })
mouseup()
the function is excuted, when the left.miffffdle or right mouse button is released while the nouse is over the html element
eg:
$("p").mouseup(function(){ alert("mouse up over p"); })
hover()
the hover() method takes two functions and is a combination of the mouseenter() and mouseleave() methods
the first function is executed when the mouse enters enters the html element, and the second function is executed when the mouse leaves the html element
eg:
$("p").hover(function(){ alert("you entered p"); },funtion(){ alert("bye! you now leave p"); })
focus()
the focus() methods attaches an event handler function to an html form the function is executed when the form field gets focus
eg:
$("input").focus(function(){ $(this).css("background-color","#cccccc"); });
blur()
the blur() method attaches an eveent handler function to an html
the function is executed when the form field loses focus
$("input").blur(function(){ $(this).css("background-color","#ffffff"); })
on()
the function attaches one or more event handlers for selected selected
elements
eg:
$("p").on("click",function(){ $(this).hide(); })
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/86896.html
摘要:一起源方法最終是用綁定事件的而方法正是等于二作用觸發(fā)綁定的事件的處理程序源碼源碼行即原生觸發(fā)事件的處理程序修正對象獲取事件的處理程序集合,結(jié)構(gòu)如下從數(shù)據(jù)緩存中獲取事件處理集合即目標元素委托目標這段代碼壓根不會執(zhí)行,因為全局搜索沒找到結(jié)構(gòu) showImg(https://segmentfault.com/img/remote/1460000019464031); 一、起源jQuery.e...
摘要:專門為事件建立一個有問題,直接退出如果是一個事件處理對象,且有屬性。參考源碼分析事件體系結(jié)構(gòu)解密事件核心綁定設(shè)計一解密事件核心委托設(shè)計二本文在上的源碼地址,歡迎來。 歡迎來我的專欄查看系列文章。 通過前面一章對于 addEvent 庫的介紹,它的兼容性超級棒,據(jù)說對于 IE4、5 都有很好的兼容性,這和 jQuery 的原理是一致的,而在 jQuery 中,有一個對象與其相對應(yīng),那就是...
摘要:不過也有自己的一套自定義事件方案??梢院褪录脕韺Ρ龋麄兌际怯脕砟M和執(zhí)行監(jiān)聽的事件。冒泡事件就是就是由內(nèi)向外冒泡的過程,這個過程不是很復(fù)雜。參考解密事件核心自定義設(shè)計三解密事件核心模擬事件四本文在上的源碼地址,歡迎來。 歡迎來我的專欄查看系列文章。 以前,我只知道,只有當對瀏覽器中的元素進行點擊的時候,才會出發(fā) click 事件,其它的事件也一樣,需要人為的鼠標操作。 showIm...
摘要:回調(diào)隊列中的元素是對象,代表一個事件回調(diào),擁有多個屬性,如等等,其中是回調(diào)函數(shù),在觸發(fā)時通過傳遞,具體的在后面講。類型是時鍵表示事件名,規(guī)則同上,鍵值表示事件觸發(fā)時的回調(diào)函數(shù)。 jQuery源碼學習之event jQuery的事件機制為異步回調(diào),事件監(jiān)聽的屬性、參數(shù)和回調(diào)的等保存在Data實例中,在元素上保存該對象的引用。有方法handle,內(nèi)部執(zhí)行dispatch;有屬性events...
閱讀 997·2021-09-26 10:15
閱讀 2088·2021-09-24 10:37
閱讀 2591·2019-08-30 13:46
閱讀 2640·2019-08-30 11:16
閱讀 2432·2019-08-29 10:56
閱讀 2603·2019-08-26 12:24
閱讀 3488·2019-08-23 18:26
閱讀 2671·2019-08-23 15:43