Onmouseover Event - W3Schools
Có thể bạn quan tâm
❮ DOM Events ❮ MouseEvent
Example
Call a function when moving the mouse pointer onto an image:
<img onmouseover="bigImg(this)" src="smiley.gif" alt="Smiley"> Try it Yourself »More examples below.
Description
The onmouseover event occurs when the mouse pointer enters an element.
The onmouseover event is often used together with the onmouseout event, which occurs when the mouse pointer leaves the element.
The onmouseover event is similar to the onmouseenter event. The difference is that the onmouseenter event does not bubble (does not propagate up the document hierarchy). See "More Examples" at the bottom of this page to better understand the differences.
Mouse Events
| Event | Occurs When |
|---|---|
| onclick | The user clicks on an element |
| oncontextmenu | The user right-clicks on an element |
| ondblclick | The user double-clicks on an element |
| onmousedown | A mouse button is pressed over an element |
| onmouseenter | The pointer is moved onto an element |
| onmouseleave | The pointer is moved out of an element |
| onmousemove | The pointer is moving over an element |
| onmouseout | The mouse pointer moves out of an element |
| onmouseover | The mouse pointer is moved over an element |
| onmouseup | The mouse button is released over an element |
See Also:
The Mouse Event Object
Tutorial:
JavaScript Events
Syntax
In HTML:
<element onmouseover="myScript"> Try it Yourself »In JavaScript:
object.onmouseover = function(){myScript}; Try it Yourself »In JavaScript, using the addEventListener() method:
object.addEventListener("mouseover", myScript); Try it Yourself »Technical Details
| Bubbles: | Yes |
|---|---|
| Cancelable: | Yes |
| Event type: | MouseEvent |
| HTML tags: | All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
| DOM Version: | Level 2 Events |
More Examples
Example
This example demonstrates the difference between the onmousemove, onmouseenter and mouseover events:
<div onmousemove="myMoveFunction()"> <p id="demo1">I will demonstrate onmousemove!</p></div> <div onmouseenter="myEnterFunction()"> <p id="demo2">I will demonstrate onmouseenter!</p> </div><div onmouseover="myOverFunction()"> <p id="demo3">I will demonstrate onmouseover!</p></div> Try it Yourself »Browser Support
onmouseover is a DOM Level 2 (2001) feature.
It is fully supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | 9-11 |
❮ DOM Events ❮ MouseEvent
★ +1 Sign in to track progressTừ khóa » Sự Kiện Hover Trong Css
-
:hover | CSS | Học Web Chuẩn
-
Hover – Thủ Thuật CSS – 1 - Truyền Mai
-
Cách Dùng Sự Kiện Hover Chuột Trong Javascript - Freetuts
-
Hover Css: Xử Lý Thay đổi Css Khi Di Chuột Vào Một Phần Tử Html
-
Bài 13: Hiệu ứng Hover Với Thuộc Tính Transition - Góc Làm Web
-
Bài 7: Hiệu ứng Hover Bằng Css Và Làm Bài Tập
-
Hover Trong CSS | Chọn Phần Tử đang Bị Người Dùng Dí Chuột Vào
-
Tạo Hiệu ứng Di Chuột (hover) Thú Vị Bằng CSS - NIIT - ICT Hà Nội
-
Top 15 Cách Dùng Hover Trong Css 2022
-
Sử Dụng Pointer-events Giả Quyết Một Số Bài Toán Css - Viblo
-
.hover() Trong JQuery - Hoclaptrinh
-
Hiệu ứng Rê Chuột Trong CSS - Quách Quỳnh
-
Sự Kiện Hover Chuột Trong Javascript - NguyenGiaTech
-
CSS Cho Các Thẻ Theo Trạng Thái (link, Hover, Visited, Active, Focus)