我在玩tooltips of jQuery UI。但是,我想要顯示圖像而不是文本。此外,圖像取決於我懸停的文字。工具提示與圖像
我有一些數字的列表,所有的同一類:
<a class="images" href="#" title="">Number 0</a>
<a class="images" href="#" title="">Number 1</a>
<a class="images" href="#" title="">Number 2</a>
當我將鼠標懸停在第二個鏈接,索引(在這種情況下,1)應該傳遞給函數,使數字1將被顯示。
但是,如何將索引傳遞給函數?
這是我暫時的解決辦法:
var number = 1; // only a temporal solution
$(".images").tooltip({
content: '<img width="100" src="http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/256/Number-' + number + '-icon.png" />'
});
是work..but如果文本被改變,那麼你的代碼不會work..See鏈接:http://jsfiddle.net/patelsumit5192/uzoqd9bh/ –