gpt4 book ai didi

javascript - 有没有办法在没有每个的情况下做到这一点?

转载 作者:行者123 更新时间:2023-11-28 21:21:20 25 4
gpt4 key购买 nike

我有很多表格单元格,我想在它们悬停时显示工具提示。每个 td 元素都有一个 rel 属性,其中包含 ajax 的请求 URI,以将内容提取到工具提示中。现在我这样做:

$('table td.tooltipped').each(function() {
var uri = $(this).attr("rel");
$(this).bt({
ajaxPath: uri,
ajaxError: "<strong>Error!</strong> Here's what we know: <em>%error</em>."
});
});

这对我来说似乎有点多余,但我不知道如何在没有每个循环的情况下做到这一点。有什么想法吗?

最佳答案

From the documentation:

Ajax dynamic path:

AjaxPath is being read from the 'href' value of the link. This is accomplished by defining the ajaxPath as an array. The first value of the array is the jQuery code to find the path value (in this case "$(this).attr('href')")...

所以看来你可以这样做:

$('table td.tooltipped').bt({
ajaxPath: ['$(this).attr("rel")'],
ajaxError: "<strong>Error!</strong> Here's what we know: <em>%error</em>."
});

我会让你测试一下。

关于javascript - 有没有办法在没有每个的情况下做到这一点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6295088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com