jquerytooltipjquery-tooltip

Jquery tooltips, get data from other attribute


Due to my page have other jquery plugin that use title attribute, so is that possible for my jquery tooltips to get data from other attribute other than "title"? http://flowplayer.org/tools/tooltip/index.html#configuration

<span class="something" title="This is title" otherattr="This is the tooltips"></span>

Solution

  • If I understand jTools Tooltip documentation correctly, if you setup the tooltip by a selector other then $("[title]") it will use the element immediately following the trigger as the tooltip content.

    So you can do something like this:

    $(document).ready(function(){
       //place a span  with class tooltip after each element with otherattr attribute placing the otherattr text inside it
       $("[otherattr]").each(function(){
           $(this).after('<span class="tooltip">' + $(this).attr("otherattr") + '</span>');
       });
    
       //when we initate the tooltip this way it will use the .tooltip span after each element. 
       $("[otherAttr]").tooltip(); 
    });