jQuery UI tooltip in wordpress site

孤人 提交于 2021-02-08 20:54:07

问题


Trying to get a tooltip working with a picture instead of text. As far it works with text in my site.

<a id="thisId" href="#" title="hello world" >ALOHA!</a>

<script>
    jQuery(document).ready(function(){
        jQuery( '#thisId' ).tooltip();
    });
</script>

This works fine.. It displays "hello world" on hover of link.

But if I try the following; working jsfiddle example ,but on my WP site it fails by simply not showing anything. Why could that be?


回答1:


This mostly happens because your WordPress theme automatically uses Bootstrap which has its own tooltips. Its tooltips also use the same function tooltip(), so it's just a naming conflict between JQuery UI & BootStrap.

To fix this you can force renaming the tooltip() function used in JQuery Ui, like this:

jQuery.widget.bridge( 'jQueryUITooltip', jQuery.ui.tooltip );

And from now on use jQueryUITooltip() instead of tooltip() to initialize JQuery UI tooltips, example:

jQuery(document).ready(function(){
    jQuery( '#thisId' ).jQueryUITooltip({
       track: true
    });
});


来源:https://stackoverflow.com/questions/28549987/jquery-ui-tooltip-in-wordpress-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!