简体   繁体   中英

jQuery Tooltip not working with detach(), appendTo, etc?

I'm trying to use this jQuery Tools ToolTip widget .

It works great in a situation like this:

    ...
<a id="A1">trigger</a> 
<script>
    $(document).ready(function () {
        $("#trigger").tooltip({ effect: 'slide' });
    });
</script>
    ...

But this will not work and it's what i want to do:

$("<a id='trigger'>trigger</a>").appendTo("body");
//console.log(myTrigger);

$("#trigger").tooltip({ effect: 'slide' });
$("#trigger").tooltip().show();

Can i dynamically add the trigger element so i can place the tooltip wherever i want? If so, how?

Sure. Theres a scripting api associated with the flowplayer plugins.

http://flowplayer.org/tools/documentation/scripting.html

This is the same for all of their plugins but the parameters will be different. Look 3/4's the way down the tooltip page for the parameters.

Works fine if i append it somewhere other than body such as a wrapper div:

$("<a id='trigger'>trigger</a>").appendTo($("#wrapper"));

$("#trigger").tooltip({ effect: 'slide' });
$("#trigger").tooltip().show();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM