Love beautiful code? We do too.
.mouseout(): Ràng buộc một xử lý tới một sự kiện mouseout (di chuyển chuột ra khỏi một thành phần), hoặc kích hoạt sự kiện mouseout lên một thành phần.
Khác biệt giữa mouseout và mouseleave là:
Xem ví dụ để hiểu rõ mouseleave và mouseout
Sự khác biệt khi có sự di chuyển lên thành phần con.
Đã được thêm vào từ phiên bản 1.0
.mouseout()
$('img').mouseout();
.mouseout(function(){...})
$('img').mouseout(function(){
alert('Bạn vừa di chuyển chuột ra khỏi một thành phần');
});
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
$('img').mouseout(function(){
$(this).css('border','5px solid green');
});
$('button').click(function(){
$('img').mouseout()
});
});
</script>
</head>
<body>
<img src="https://hoclaptrinh.vn/themes/client/img/code-screen.jpg" />
<button>Click</button>
</body>
</html>
Hiển thị trình duyệt:
Khi click vào button, ta đã kích hoạt được giá trị mouseout vào <img />
, giống như vừa di chuyển chuột ra khỏi <img />
.
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
$('img').mouseout(function(){
$(this).css('border','5px solid green');
});
});
</script>
</head>
<body>
<img src="https://hoclaptrinh.vn/themes/client/img/code-screen.jpg" />
</body>
</html>
Hiển thị trình duyệt:
Khi di chuyển chuột ra khỏi <img />
ta sẽ thấy được kết qủa.
Hoclaptrinh.vn © 2017
From Coder With
Unpublished comment
Viết câu trả lời