HTML
<div module="product_listnormal">
<ul>
<li>
<input type="checkbox" class="{$product_compare_class} {$product_compare_display|display}">
<div id="prdImgWrapper">
<a href="/product/detail.html{$param}" class="prdImg"><img src="{$image_medium}" alt="" class="prdImgImg"/></a>
</div>
.....
所以我在img标签中添加了onmouseover
<a href="/product/detail.html{$param}" class="prdImg"><img src="{$image_medium}" onmouseover="this.src={$image_medium} + 'aaa'" alt="" class="prdImgImg"/></a>
但它不调用 {$image_medium}aaa 链接 怎么了?
ex) 如果 $image_medium = 111.png
$image_medium + aaa = 111aaa.png
最佳答案
我像这样在鼠标悬停和鼠标离开时使用
onmouseover='this.src = this.src.replace(".jpg","_2.jpg")' onmouseleave='this.src = this.src.replate("_2.jpg", ".jpg")'
此源可以使用所有图片
关于javascript - 如何更改 img src 链接鼠标悬停?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27011139/