Love beautiful code? We do too.
.mousedown(): Ràng buộc một xử lý tới một sự kiện mousedown (click chuột), hoặc kích hoạt sự kiện mousedown lên một thành phần.
Đã được thêm vào từ phiên bản 1.0
.mousedown()
$('input').mousedown();
.mousedown(function(){...})
$('input').mousedown(function(){
alert('Bạn vừa click chuột');
});
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').mousedown(function(){
$(this).css('border','5px solid green');
});
$('button').click(function(){
$('img').mousedown()
});
});
</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ị mousedown vào <img />
, giống như vừa click vào <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').mousedown(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 click vào <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