3
Good morning, my problem is this: I have a gif of a Bulbasaur and I want that when I pass the mouse on top of it the gif change to another, but when I finish the animation of 2°; gif I want it to automatically go back to 1°, has how to do this since gif keeps rebooting itself?
My code:
<style>
img{
width: 6%
}
</style>
</head>
<body>
<img src="Bulbasaur_XY.gif" id="i">
<script>
var imagem = document.getElementById('i')
imagem.addEventListener('mouseenter', entrar)
imagem.addEventListener('mouseout',sair)
function entrar(){
document.getElementById('i').src="Bulbasaur_XY_AttackAnimation_Sprite (1).gif"
}
function sair(){
document.getElementById('i').src="Bulbasaur_XY.gif"
}
</script>
</body>
Link to the gifs: 1° gif = https://vignette.wikia.nocookie.net/pokemon/images/0/00/Bulbasaur_XY.gif/revision/latest?cb=20140319081443
I also wanted to know if there is how to get the 2 gif of the msm size, since the first and width of each is different and I am using the img msm tag.
Daniel, some information is missing from your question. What happens if the mouse exits the element in the middle of the 2nd GIF execution? And if the mouse is repeatedly entering and exiting the element?
– fernandosavio
@Daniel Lucas About the image size this article: https://www.w3schools.com/tags/att_img_width.asp
– Maury Developer
@fernandosavio what I want is that when the mouse passes in element 1 it goes to element 2, only that until the end of the animation of element 2 the mouse events are impossible to happen
– Akali