1

I have the following code. I want to reference the trigger element and get the tag value in onShow(). How can I do that? Thanks

<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) {
    }
});
}
Yang Sun
  • 11
  • 1

1 Answers1

3

From 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){},

So, you should use, this to reference the element.

And, for the other part of your question, you can use 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
        }
    });
});
nicosantangelo
  • 13,216
  • 3
  • 33
  • 47