jQuery工具:工具提示,jQuery对"this"的引用属性 [英] jQuery Tools: Tooltip, jQuery reference to "this" attribute
本文介绍了jQuery工具:工具提示,jQuery对"this"的引用属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为表格中的单元格实现工具提示,我需要能够获取目标的data-message
属性.
I'm implementing a Tooltip for cells within table and I need to be able to grab the target's data-message
attribute.
$("#pricing_plans_table .sku_tooltip").tooltip({
// each trashcan image works as a trigger
tip: '#' + $(this).attr('data-message'),
// move tooltip a little bit to the right
offset: [0, 15],
// there is no delay when the mouse is moved away from the trigger
delay: 0
});
那是行不通的.我收到找不到[object Object]的工具提示" ...我不太确定如何正确引用目标.
That doesn't work. I get "Cannot find tooltip for [object Object]" ... I'm not quite sure how to reference the target correctly.
推荐答案
我认为您无法在这样的地图中使用this
.试试:
I don't think you can use this
inside a map like that. Try:
$("#pricing_plans_table .sku_tooltip").each(function(i,el) {
var tipstr = $(this).attr('data-message');
$(this).tooltip({
tip: '#' + tipstr,
offset: [0, 15],
delay: 0
});
});
这篇关于jQuery工具:工具提示,jQuery对"this"的引用属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文