Jquery tooltips, get data from other attribute

jquery tooltip auto adjust position
jquery get data attribute value
jquery tooltip css
get attribute jquery
jquery find element with data attribute
jquery get all attributes
jquery remove attribute
jquery tooltip html

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>

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(); 
});

Tooltip using data- attribute, 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  The jQuery attr() method is used to get or set attributes and values of the selected html elements. For get an attribute’s value use the below syntax. $(selector).attr(attribute); Using the below syntax you can set an attribute and values. $(selector).attr(attribute,value); To set an attribute and value by using a function using this below syntax.

You can specify a function as the content for the tooltip and programmatically get the content from the attribute. In this case, you wanted the attribute 'otherattr', so you can try the following:

$(".something").tooltip({
    "content": function(){ 
        return $(this).attr("otherattr"); 
    }
});

I had to dig through some source code to figure this one out, by default the tooltip's 'content' can be found by doing

$(".something").tooltip("option", "content")

and see that it returns:

function (){var e=t(this).attr("title")||"";return t("<a>").text(e).html()}

So just write your own instead of using the default function. Hope that helps!

JavaScript & JQuery: The Missing Manual, Hi: I am trying to use the new tooltip widget on elements that do NOT have a title attribute, but have a data-tooltip attribute. I though this would  Tooltips can be attached to any element. When you hover the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip. But as it's not a native tooltip, it can be styled. Any themes built with ThemeRoller will also style tooltips accordingly.

$(".something").tooltip({
    items: '[otherattr]',
    content: function(){ 
        return $(this).attr("otherattr"); 
    }
});

.attr(), The part inside the $()—$this.attr('data-tooltip')—uses jQuery's .attr() function to retrieve In other words, this code takes the current trigger element, looks for a  An element's data-* attributes are retrieved the first time the data() method is invoked upon it, and then are no longer accessed or mutated (all values are stored internally by jQuery). Every attempt is made to convert the attribute's string value to a JavaScript value (this includes booleans, numbers, objects, arrays, and null).

Tooltip, Get the value of an attribute for the first element in the set of matched elements Convenience: It can be called directly on a jQuery object and chained to other  Positioning Tooltips. By default, the tooltip will appear on top of the element. Use the data-placement attribute to set the position of the tooltip on top, bottom, left or the right side of the element:

Tooltip Widget, When you hover the element with your mouse, the title attribute is displayed in a little box Tooltips are also useful for form elements, to show some additional  Add data attributes to register an element with typeahead functionality as shown in the example above. Via JavaScript. Call the typeahead manually with: $('.typeahead').typeahead() Options. Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-source="".

Bootstrap JS Popover Reference, As a result, jQuery UI does not guarantee any level of support for tooltips attached Customize if you're using something other than the title attribute for the tooltip Note: For options that have objects as their value, you can get the value of a  5. Use HTML inside your tooltips. Tooltipster allows you to use any HTML markup inside your tooltips. It means that you can insert things like images and text formatting tags. Instead of a title attribute, use a data-tooltip-content attribute to provide a selector that corresponds to the HTML element of your page that should be used as content

Comments
  • What tooltip are you using?qtip?qtip2?Provide as much info as possible when you ask a question.
  • Have you tried: $(".something[otherattr]").tooltip();
  • @Nicola: He provided the link to the tooltip lib he is using.
  • $(".something[otherattr]").tooltip(); cant really work, tried.