HTML onwheel 이벤트 속성은 사용자가 HTML 문서의 HTML 요소에서 마우스 휠을 움직일 때 트리거됩니다.
구문
다음은 구문입니다 -
<tagname onwheel=”script”>Content</tagname>
HTML onwheel 이벤트 Attribute −
의 예를 살펴보겠습니다.예시
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
text-align: center;
padding: 20px;
}
.wheel {
border: 2px solid #fff;
padding: 10px;
}
</style>
</head>
<body>
<h1>HTML onwheel Event Attribute Demo</h1>
<p onwheel='wheelFn()' class='wheel'>This is a paragraph with some dummy content.
This is a paragraph with some dummy content. This is a paragraph with some dummy content.
This is a paragraph with some dummy content. This is a paragraph with some dummy content.
This is a paragraph with some dummy content. This is a paragraph with some dummy content.
This is a paragraph with some dummy content.</p>
<p>Move the wheel of the mouse up or down on above paragraph</p>
<script>
function wheelFn() {
document.body.style.background = "linear-gradient(45deg, #8BC6EC 0%, #9599E2 100%) no-repeat";
document.body.style.color = "#fff";
}
</script>
</body>
</html> 출력

이제 단락 요소에서 마우스 휠을 위 또는 아래로 이동하여 onwheel 이벤트 속성이 작동하는 방식을 관찰하십시오.
