gpt4 book ai didi

javascript - 如何在cluetip中引用trigger元素?

转载 作者:行者123 更新时间:2023-11-30 13:04:44 26 4
gpt4 key购买 nike

我有以下代码。我想引用触发元素并在 onShow() 中获取标记值。我怎样才能做到这一点?谢谢

<a class="tips" tag="12">TEST 01</a>
<a class="tips" tag="123">TEST 02</a>
<a class="tips" tag="1234">TEST 03</a>
<a class="tips" tag="12345">TEST 04</a>

$(document).ready(function () {
$('a.tips').cluetip({
splitTitle: "|",
width: '500',
sticky: true,
closePosition: 'title',
dropShadow: true,
onShow: function (ct, ci) {
}
});
}

最佳答案

来自 the docs

    // function to run just after clueTip is shown. It can take two arguments:
// the first is a jQuery object representing the clueTip element;
// the second a jQuery object represeting the clueTip inner div.
// Inside the function, this refers to the element that invoked the clueTip
onShow: function(ct, ci){},

因此,您应该使用 this 来引用该元素。

并且,对于您问题的另一部分,您可以使用 jQuery:

$(document).ready(function () {
$('a.tips').cluetip({
splitTitle: "|",
width: '500',
sticky: true,
closePosition: 'title',
dropShadow: true,
onShow: function(ct, ci){
var selectedTag = $(this).attr("tag"); //get the tag
}
});
});

关于javascript - 如何在cluetip中引用trigger元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16112612/

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