【发布时间】:2013-08-31 19:32:30
【问题描述】:
我正在使用 Magento 1.7.0.2,我有这个代码:
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this- >stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(275); ?>" width="325" height="488" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" onmouseover="this.src='<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(325) ?>';" onmouseout="this.src='<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(325) ?>';" />
此代码在鼠标悬停时使用缩略图图像更改类别页面中产品的基本图像。过渡是即时的。
当我使用鼠标悬停时,我想为基本图像添加淡出效果并为缩略图图像添加淡入效果。这样我就可以在图像之间创建一个很好的过渡效果。
我试过这个 jquery 代码但没有用:
function fadeOut(element, src){
element.fadeIn('slow', function() {
this.attr("src", src);
});}
并将 onmouseover 替换为
onmouseover="fadeOut(this, 'http://imagesource.jpg')"
【问题讨论】:
-
您尝试过但没有成功的 jQuery 代码是什么?修改可能比从头开始制定解决方案更有效......您实际上也可以从错误的地方学到一些东西。
-
也请分享生成的html而不是magento代码
标签: javascript jquery magento magento-1.7