我有一个产品目录。当您滚动缩略图时 - 产品描述出现在工具提示 (Cluetip) 中。激活 Cluetip 时,我需要在相关图像周围出现阴影。
为此,我在图像周围创建了带有阴影的单独 div,这就是我在激活 Cluetip 时定位 div 的方式:
onActivate: function() { $("#shadow").fadeIn(1000); }
但问题是在我的情况下,CMS 会动态生成 div 的 ID,因此它们的名称有 #shadow6、#shadow8、#shadow17 等。
我的问题是:一旦激活了 Cluetip,如何定位特定的动态 div 的 ID?
jQuery:
<script type="text/javascript">
$(document).ready(function () {
$('.thumbnail').cluetip({
fx: {
open: 'fadeIn',
openSpeed: '2000'
},
showTitle: false,
cursor: 'pointer',
positionBy: 'auto',
height: '210px',
topOffset: 0,
leftOffset: 20,
local: true,
sticky: true,
mouseOutClose: true,
onActivate: function () {
$("#shadow").fadeIn(1000);
},
onHide: function () {
$("#shadow").fadeOut(300);
}
});
});
</script>
HTML/PHP(在循环中)
<div id="shadow{$obj_id}" style="position: absolute; display:none;
width:150px; height:190px;"></div>
<div class="thumbnail">
<img src="/images/product.jpg" />
</div>
实际代码
<div id="shadow1"></div>
<a href="/shoe-model-name.html">
<span class="cm-template-box" template="common_templates/image.tpl" id="te3">
<img class="cm-template-icon hidden" src="/skins/test/customer/images/icons/layout_edit.gif" width="16" height="16" alt="" />
<img class="thumbnail" rel="#popupz1" src="/images/product-tmb.jpg" width="150" height="180" alt="" /></span>
</a>