i using jquery plugin, tooltipster, , everytime try attribute of hover element, svg shape, 'undefined', example "$(this).attr('id')", whenever use $(this) "[object] [object]". how can access attributes of hover/clicked element id, title? thank you
$(document).ready(function() { $('circle').tooltipster({ content: $('<span><img src="my-image.png" /><br>' + $(this).attr('id') + '</span>') }); });
this isn't expecting .
a common pattern initializing plugin requires element specific data passed options initialize inside each loop.
$('circle').each(function(index, element){ // "this" element instance $(this).tooltipster({ content: $('<span><img src="my-image.png" /><br>' + this.id + '</span>') }); });
Comments
Post a Comment