JQuery版本和编辑工具提示

时间:2017-06-08 04:14:36

标签: javascript jquery tooltip jquery-ui-tooltip

我正在使用包含以下内容的工具提示编辑脚本:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="http://static.tumblr.com/iuw14ew/VSQma1786/jquery.style-my-tooltips.js"></script>

<script>
    (function($){
        $(document).ready(function(){
            $("a[title]").style_my_tooltips({
                tip_follows_cursor: true,
                tip_delay_time: 90,
                tip_fade_speed: 600,
                attribute: "title"
            });
        });
    })(jQuery);
</script>

但是,由于我正在使用的另一个脚本,我需要使用这个版本的jQuery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

尝试使用2.1.4会破坏工具提示样式。救命?我是jQuery和Javascript的超级新手。

1 个答案:

答案 0 :(得分:0)

正如@Ali在评论中所说,你可以使用jQuery的noConflict函数。

默认情况下,jQuery使用$作为简写函数名称。使用jQuery.noConflict(),您可以将其绑定到其他内容。

这意味着,如链接的答案所示,您可以执行以下操作:

对于1.7版,您可以执行以下操作:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript"> var jQ = $.noConflict(true); </script>

现在,您可以使用$(document).ready()代替jQ(document).ready()来访问jQuery 1.7函数。

仍然可以通过$访问jQuery 2.1.4。

请注意,jQuery 1.7已有6年历史,可能已经过时了。考虑寻找您正在使用的更新版本的Tooltip库。

Bootstrap has the functionality you're looking for!

相关问题