当我将鼠标悬停在此页面上的图片上时,我应该将上面较大的 div 元素的 src 属性更新为我当前悬停在其上的图像的图像 url。
我的断点达到
"$('#image').on('悬停', function() {"
行,但实际上不会在下一行设置 div 元素的 url 属性。任何指针?
function upDate(previewPic) {
let newUrl = previewPic.src;
$('#image').on('hover', function() {
$('#image').attr("url", newUrl);
});
};
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div id="image">
Hover over an image below to display here.
</div>
<img alt="Batter is ready" class="preview" onmouseout="unDo()" onmouseover="upDate(this)" src="https://cdn.sallysbakingaddiction.com/wp-content/uploads/2017/06/moist-chocolate-cupcakes-7.jpg">
<img alt="Perfect Baking" class="preview" onmouseout="unDo()" onmouseover="upDate(this)" src="https://cdn.sallysbakingaddiction.com/wp-content/uploads/2017/06/moist-chocolate-cupcakes-6.jpg">
<img alt="Yummy yummy cup cake" class="preview" onmouseout="unDo()" onmouseover="upDate(this)" src="https://cdn.sallysbakingaddiction.com/wp-content/uploads/2017/06/moist-chocolate-cupcakes-5.jpg">
斯蒂芬大帝
白猪掌柜的
相关分类