HTML事件屬性onwheel

2018-01-05 13:58 更新

HTML事件屬性onwheel


觸發(fā) onwheel 屬性事件當(dāng)鼠標(biāo)滾輪向上或向下滾動(dòng)時(shí)。

HTML5中的新功能

onwheel 屬性是HTML5中的新特性。

句法

<element onwheel="script or Javascript function name">

支持的標(biāo)簽

所有HTML元素

瀏覽器兼容性

onwheel Yes Yes Yes Yes Yes


例子

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
    border: 1px solid black;
}
</style>
</head>
<body>

<div id="myDIV" onwheel="myFunction()">
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
</div>

<script>
function myFunction() {
    console.log("wheel");
}
</script>

</body>
</html>

Click to view the demo



以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)