How to trigger the tooltip from a content has just created dynamically from jquery?
I use append function to append a "p"
element into a content and with title attribute as well.
Every time I need to hover twice on the a newly created element then the tooltip
box will appear. Otherwise hovering on the element first time will show nothing always.
This is my tooltip
function. Or maybe I can get the class name and do the matching somehow. Please do guide me.
$(".tooltip_class").tooltip({
show: null,
position: {
my: "left top",
at: "left bottom"
},
open: function( event, ui ) {
ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" );
}
});
How to trigger the tooltip from a content has just created dynamically from jquery?
I use append function to append a "p"
element into a content and with title attribute as well.
Every time I need to hover twice on the a newly created element then the tooltip
box will appear. Otherwise hovering on the element first time will show nothing always.
This is my tooltip
function. Or maybe I can get the class name and do the matching somehow. Please do guide me.
$(".tooltip_class").tooltip({
show: null,
position: {
my: "left top",
at: "left bottom"
},
open: function( event, ui ) {
ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" );
}
});
Share
Improve this question
edited Jan 9, 2017 at 11:34
Raviteja
3,48923 gold badges45 silver badges74 bronze badges
asked Mar 16, 2014 at 18:07
MichaelMichael
891 gold badge1 silver badge8 bronze badges
5
- can you post a fiddle showing the problem? or the code you're using for the tooltip? – T J Commented Mar 16, 2014 at 18:33
- currently my code is $(document).tooltip({ show: null, position: { my: "left top", at: "left bottom" }, open: function( event, ui ) { ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" ); } }); – Michael Commented Mar 16, 2014 at 18:35
- I want to get the class name so i can match it to whether to show the tooltip or not. because i have other element which contain title as well but not all title must show inside a jquery tooltip – Michael Commented Mar 16, 2014 at 18:37
- please update the code in your question, not everyone reads the ments.. – T J Commented Mar 16, 2014 at 18:39
- @Michael You need to put the HTML code here, if you want others to help you. – Foreever Commented Mar 19, 2014 at 4:58
1 Answer
Reset to default 5You do not need to put the content as title attribute value. Instead the content can be added in jQuery as follows:
Javascript
$( document ).tooltip();
$('#selector').tooltip( "option", "content", "TOOLTIP CONTENT" );
HTML
<span class="help">
<a id="selector" title="">
What's this?
</a>
</span>
See Demo