gpt4 book ai didi

jquery - 仅当鼠标悬停在图片上时如何运行我的 .gif 文件?

转载 作者:行者123 更新时间:2023-12-01 06:48:31 26 4
gpt4 key购买 nike

仅当鼠标悬停在图片上时如何运行我的 .gif 文件?

演示:http://jsfiddle.net/pHcXa/

<html>
<body>

<div id="img_wrap" class="static">

<img id="animated" src="database.gif">
<img id="static" src="database.png">

<script type="text/javascript">


$(function(){
$('#img_wrap').on( 'mouseenter', function() {
$(this).toggleClass('animated', 'static');

})
})
</script>

</body>
</html>

最佳答案

或者你可以使用CSS来做到这一点

fiddle :http://jsfiddle.net/parslook/pHcXa/3/

CSS

body {
background-color:#282828;
}


.image {
background: url(http://swish.wodip.opole.pl/forum/files/thumbs/t_spirala_157.png);
width:300px;
height:310px;
background-size:300px;
}

.image:hover {
background: url(http://www.laboiteverte.fr/wp-content/uploads/2010/10/gif-psychedelique-hypnose-animation-11.gif);
width:300px;
height:310px;
background-size:300px;
}

html

<div class="image">

</div>

关于jquery - 仅当鼠标悬停在图片上时如何运行我的 .gif 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18767258/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com