我已尝试过此代码:
$( document ).ready(function() {
$("[data-preview]" ).each(function(){
$(this).tooltip({ content: function(){
return '<img src="/img/hover/'+$(this).attr("data-preview")+'.png" />';
}, track: true, tooltipClass: "hoverpreview" });
});
});
还有这段代码:
$( document ).ready(function() {
$("[data-preview]" ).tooltip({ content: function(){
return '<img src="/img/hover/'+$(this).attr("data-preview")+'.png" />';
}, track: true, tooltipClass: "hoverpreview" });
});
这是HTML:
<div class="productnav doors">
<ul>
<li><a href="/products/f-series" class="active" alt="F-SERIES" title="F-SERIES" data-preview="thumb-fseries">F-SERIES</a></li>
<li><a href="/products/dw-series" class="" alt="DW SERIES" data-preview="thumb-dwseries">DW SERIES</a></li>
</ul>
</div>
但它只会显示第一个工具提示。