Firstly, here is the code that works:
$(function() { $('#warning-binder-element').tooltip({ items: '.warning', tooltipClass: 'warning-tooltip', content: function () { return $(this).prev('.warning-toast').html(); }, position: { my: "right bottom", at: "right top-10" } }); $('#info-binder-element').tooltip({ items: '.info', tooltipClass: 'info-tooltip', content: function () { return $(this).closest('.doo-hicky').next('.info-toast').html(); }, position: { my: "left bottom", at: "left+10 top-10" } }); });
A few notes above:
- The selector for
.tooltip() is not the element that you want to enable the tooltip, it is the element on the page to which the tooltip object and related events are attached. - If you try to link two tooltips with the same object, only the last one remains, so binding as to
$(document) will not work (thatβs why I linked two different tooltips with two different elements on the page). - you can attach a tooltip object to an element that receives a tooltip, but if you use the class selector, this can lead to unpleasant consequences.
source share