Jquery: Get 'title' attribute of each element, not just the first -
i trying display title attribute of each element class "tooltip", using jquery plugin tooltipster.
but whatever reason, "title" of first element - every element on page.
<i class="tooltip game-1" title="219"></i> <i class="tooltip game-2" title="30"></i> <i class="tooltip game-3" title="122"></i> $(document).ready(function() { $('.tooltip').tooltipster({ content: $(''+$(this).attr('title')+' people played game') }); });
i 219 on , over.
try using each()
apply tooltipster()
each .tooltip
element seperately.
$(document).ready(function() { $('.tooltip').each(function(){ $(this).tooltipster({ content: $(''+$(this).attr('title')+' people played game') }); }); });
Comments
Post a Comment