通过将参数e传递给匿名函数以获取内容,可以访问目标。
gridToolTipz = $('#grid').kendoTooltip({
filter: "td[role=gridcell]",
content: function (e) {
var target = e.target; // the element for which the tooltip is shown
...
},
show: function(e) {
var target = e.target; // the element for which the tooltip is shown
...
}
});
有可能在节目中实现同样的目标吗?上面的代码不起作用。
您总是可以通过调用tooltip.target():来访问目标元素
var toolTip = $('#grid').kendoTooltip({
filter: "td[role=gridcell]",
content: function (e) {
var target = e.target; // the element for which the tooltip is currently shown
return "Content is: " + target.text(); // use current element for content
},
show: function (e) {
var target = this.target(); // the element for which the tooltip is currently shown
if (target) {
console.log("now showing with content: ");
console.log(target.text());
}
}
}).data("kendoTooltip");
请参阅演示:http://jsfiddle.net/lhoeppner/mcpxj/