tooltip on dynamic created content in jquery

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

You 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


$( document ).tooltip(); $('#selector').tooltip( "option", "content", "TOOLTIP CONTENT" );

链接地址: http://www.djcxy.com/p/80910.html

上一篇: 检查仅当其他元素是鼠标上下/进入时出现的元素

下一篇: 工具提示在jQuery中动态创建的内容