Skip to content

Commit dd45e1a

Browse files
authored
hover vídeo com jquery
1 parent 1dacf5e commit dd45e1a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

video.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Vídeo</title>
7+
<style>
8+
video{
9+
width: 800px;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<video src="exemplo.mp4" id="video" preload></video>
15+
16+
17+
<script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
18+
<script>
19+
/*JQuery*/
20+
/*
21+
var $video = $('#video');
22+
$video.on('mouseenter focus', function(){
23+
$video.get(0).play();
24+
});
25+
$video.on('mouseout blur', function(){
26+
$video.get(0).pause();
27+
});
28+
*/
29+
30+
/*Javascript*/
31+
var video = document.getElementById('video')
32+
video.addEventListener('mouseover', function() {
33+
video.play()
34+
}, false);
35+
36+
video.addEventListener('mouseout', function() {
37+
video.pause()
38+
}, false);
39+
</script>
40+
</body>
41+
</html>

0 commit comments

Comments
 (0)