久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔

HTML事件

2023-11-07 220

HTML 事件是指在 HTML 元素上發(fā)生的特定事情,比如頁面加載、鼠標點擊、鍵盤按下等。通過使用 HTML 事件,可以執(zhí)行 JavaScript 代碼來響應(yīng)用戶的操作或者處理頁面的各種交互。

一、HTML事件

以下是一些常見的 HTML 事件:

1、onload:當(dāng)頁面加載完成時觸發(fā),通常用于執(zhí)行初始化操作。

2、onclick:當(dāng)用戶點擊某個元素時觸發(fā),常用于按鈕或鏈接的點擊事件。

3、onmouseover 和 onmouseout:當(dāng)鼠標移入或移出元素時觸發(fā),常用于實現(xiàn)鼠標懸停效果。

4、onchange:當(dāng)元素的值發(fā)生改變時觸發(fā),常用于表單元素的值變化事件。

在 HTML 中,可以通過在標簽內(nèi)部使用相應(yīng)的事件屬性來綁定事件處理程序,例如:

<button onclick="myFunction()">點擊我</button>

在上面的例子中,當(dāng)用戶點擊按鈕時,會調(diào)用名為 myFunction 的 JavaScript 函數(shù)。

除了以上列舉的事件之外,還有許多其他事件,如鍵盤事件、表單事件等,它們可以幫助我們實現(xiàn)豐富的交互效果和動態(tài)功能。

二、窗口事件屬性

由窗口觸發(fā)該事件 (適用于標簽):

屬性 描述
onafterprint script 在打印文檔之后運行腳本
onbeforeprint script 在文檔打印之前運行腳本
onbeforeonload script 在文檔加載之前運行腳本
onblur script 當(dāng)窗口失去焦點時運行腳本
onerror script 當(dāng)錯誤發(fā)生時運行腳本
onfocus script 當(dāng)窗口獲得焦點時運行腳本
onhaschange script 當(dāng)文檔改變時運行腳本
onload script 當(dāng)文檔加載時運行腳本
onmessage script 當(dāng)觸發(fā)消息時運行腳本
onoffline script 當(dāng)文檔離線時運行腳本
ononline script 當(dāng)文檔上線時運行腳本
onpagehide script 當(dāng)窗口隱藏時運行腳本
onpageshow script 當(dāng)窗口可見時運行腳本
onpopstate script 當(dāng)窗口歷史記錄改變時運行腳本
onredo script 當(dāng)文檔執(zhí)行再執(zhí)行操作(redo)時運行腳本
onresize script 當(dāng)調(diào)整窗口大小時運行腳本
onstorage script 當(dāng) Web Storage 區(qū)域更新時(存儲空間中的數(shù)據(jù)發(fā)生變化時)運行腳本
onundo script 當(dāng)文檔執(zhí)行撤銷時運行腳本
onunload script 當(dāng)用戶離開文檔時運行腳本

三、表單事件

表單事件在HTML表單中觸發(fā) (適用于所有 HTML 元素, 但該HTML元素需在form表單內(nèi)):

屬性 描述
onblur script 當(dāng)元素失去焦點時運行腳本
onchange script 當(dāng)元素改變時運行腳本
oncontextmenu script 當(dāng)觸發(fā)上下文菜單時運行腳本
onfocus script 當(dāng)元素獲得焦點時運行腳本
onformchange script 當(dāng)表單改變時運行腳本
onforminput script 當(dāng)表單獲得用戶輸入時運行腳本
oninput script 當(dāng)元素獲得用戶輸入時運行腳本
oninvalid script 當(dāng)元素?zé)o效時運行腳本
onreset script 當(dāng)表單重置時運行腳本。HTML 5 不支持。
onselect script 當(dāng)選取元素時運行腳本
onsubmit script 當(dāng)提交表單時運行腳本

四、鍵盤事件

屬性 描述
onkeydown script 當(dāng)按下按鍵時運行腳本
onkeypress script 當(dāng)按下并松開按鍵時運行腳本
onkeyup script 當(dāng)松開按鍵時運行腳本

五、鼠標事件

通過鼠標觸發(fā)事件, 類似用戶的行為:

屬性 描述
onclick script 當(dāng)單擊鼠標時運行腳本
ondblclick script 當(dāng)雙擊鼠標時運行腳本
ondrag script 當(dāng)拖動元素時運行腳本
ondragend script 當(dāng)拖動操作結(jié)束時運行腳本
ondragenter script 當(dāng)元素被拖動至有效的拖放目標時運行腳本
ondragleave script 當(dāng)元素離開有效拖放目標時運行腳本
ondragover script 當(dāng)元素被拖動至有效拖放目標上方時運行腳本
ondragstart script 當(dāng)拖動操作開始時運行腳本
ondrop script 當(dāng)被拖動元素正在被拖放時運行腳本
onmousedown script 當(dāng)按下鼠標按鈕時運行腳本
onmousemove script 當(dāng)鼠標指針移動時運行腳本
onmouseout script 當(dāng)鼠標指針移出元素時運行腳本
onmouseover script 當(dāng)鼠標指針移至元素之上時運行腳本
onmouseup script 當(dāng)松開鼠標按鈕時運行腳本
onmousewheel script 當(dāng)轉(zhuǎn)動鼠標滾輪時運行腳本
onscroll script 當(dāng)滾動元素的滾動條時運行腳本

六、多媒體事件

通過視頻(videos)、圖像(images)或者音頻(audio) 觸發(fā)該事件,多應(yīng)用于HTML媒體元素比如:

屬性 描述
onabort script 當(dāng)發(fā)生中止事件時運行腳本
oncanplay script 當(dāng)媒介能夠開始播放但可能因緩沖而需要停止時運行腳本
oncanplaythrough script 當(dāng)媒介能夠無需因緩沖而停止即可播放至結(jié)尾時運行腳本
ondurationchange script 當(dāng)媒介長度改變時運行腳本
onemptied script 當(dāng)媒介資源元素突然為空時(網(wǎng)絡(luò)錯誤、加載錯誤等)運行腳本
onended script 當(dāng)媒介已抵達結(jié)尾時運行腳本
onerror script 當(dāng)在元素加載期間發(fā)生錯誤時運行腳本
onloadeddata script 當(dāng)加載媒介數(shù)據(jù)時運行腳本
onloadedmetadata script 當(dāng)媒介元素的持續(xù)時間以及其他媒介數(shù)據(jù)已加載時運行腳本
onloadstart script 當(dāng)瀏覽器開始加載媒介數(shù)據(jù)時運行腳本
onpause script 當(dāng)媒介數(shù)據(jù)暫停時運行腳本
onplay script 當(dāng)媒介數(shù)據(jù)將要開始播放時運行腳本
onplaying script 當(dāng)媒介數(shù)據(jù)已開始播放時運行腳本
onprogress script 當(dāng)瀏覽器正在取媒介數(shù)據(jù)時運行腳本
onratechange script 當(dāng)媒介數(shù)據(jù)的播放速率改變時運行腳本
onreadystatechange script 當(dāng)就緒狀態(tài)(ready-state)改變時運行腳本
onseeked script 當(dāng)媒介元素的定位屬性 [1] 不再為真且定位已結(jié)束時運行腳本
onseeking script 當(dāng)媒介元素的定位屬性為真且定位已開始時運行腳本
onstalled script 當(dāng)取回媒介數(shù)據(jù)過程中(延遲)存在錯誤時運行腳本
onsuspend script 當(dāng)瀏覽器已在取媒介數(shù)據(jù)但在取回整個媒介文件之前停止時運行腳本
ontimeupdate script 當(dāng)媒介改變其播放位置時運行腳本
onvolumechange script 當(dāng)媒介改變音量亦或當(dāng)音量被設(shè)置為靜音時運行腳本
onwaiting script 當(dāng)媒介已停止播放但打算繼續(xù)播放時運行腳本

七、其他事件

屬性 描述
onshow script 當(dāng) 元素在上下文顯示時觸發(fā)
ontoggle script 當(dāng)用戶打開或關(guān)閉 元素時觸發(fā)
  • 廣告合作

  • QQ群號:4114653

溫馨提示:
1、本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享網(wǎng)絡(luò)內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。郵箱:2942802716#qq.com(#改為@)。 2、本站原創(chuàng)內(nèi)容未經(jīng)允許不得轉(zhuǎn)裁,轉(zhuǎn)載請注明出處“站長百科”和原文地址。
HTML事件
上一篇: HTML空格