javascript - 如何解决 onmouseover 事件中的过渡问题?
问题描述
当我将鼠标悬停在图片上时,图片会发生变化,但我无法添加过渡效果。谁能指导我如何实现这一目标?
<img src="/responsiveweb/2.jpeg" id="image1" alt="" style="width:300px; height:300px; object-fit:contain">
<script>
var resim = document.getElementById("image1");
resim.onmouseover = function() {
resim.src = "/responsiveweb/3.jpeg";
}
resim.onmouseout = function() {
this.src = "/responsiveweb/2.jpeg";
}
resim.style.transition = "all 2s";
</script>
解决方案
推荐阅读
- javascript - 在浏览器中训练后在 tensorflow.js 中合并和保存模型
- spring-boot - Spring Boot 无法登录
- javascript - Alexa Skill Kit - AudioPlayer 元数据图像
- database - 将群发短信的记录保存到 db laravel
- function - 将函数从 V1 转换为 V4 pinescript
- python - 终止shell脚本的子进程Popen问题
- wordpress - 无法使用类将_meta_box 添加到我的 woocommerce 产品页面
- javascript - p5.js 的光标跟踪算法
- c# - 如何通过错误视图传递更详细的消息?
- google-chrome - 在 windows 中共享桌面音频时,chrome 如何进行回声消除