jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery ui工具提示修改为仅在点击时工作打开和关闭一次大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@L_197_0@:1.8.2
jquery ui:1.9.1

修改了实现jquery ui工具@L_489_2@的认方式,因此它可以在点击而不是悬停时工作.

“a”标记是您单击以激活工具@L_489_2@的内容,但未定义为工具@L_489_2@.工具@L_489_2@&工具@L_489_2@内容放在’a’标记之后并用css隐藏,因此您无法悬停或查看内容.

<a class="tooltip-click" id="tt3">asdf</a><span class="tooltip-tick" title="">&nbsp;</span>
<div class="tooltip-content">3</div>

在工具@L_489_2@实现中,我使用“content:”属性获取工具@L_489_2@定义旁边的div的内容,而不是使用“title”

我还在工具@L_489_2@定义中有一个函数,如果单击工具@L_489_2@内容,它将关闭工具@L_489_2@.

$('.tooltip-tick').tooltip({
        position: { 
            my: "left+15 center",at: "right center",using: function( position,FeedBACk ) {
                        $( this ).css( position );
                        //function to close tooltip when content is touched                            
                        $('.ui-tooltip-content').click(function(){
                            $(".tooltip-tick").tooltip("close");
                        });   
        }},//the content of the div next to the tooltip instead of using title
        content: function(){
            return $(this).next().html();
        }   
    });

单击A标签时,它首先关闭所有打开的工具@L_489_2@,然后打开所需的工具@L_489_2@:

$('.tooltip-click').click(function () {
        //first i close open tooltips
        if($(".ui-tooltip").length) $(".tooltip-tick").tooltip("close");
        //then open the tooltip next to the a tag                
        $($(this).next('.tooltip-tick')).tooltip('open');
    });

一切正常,但只有一次.
http://jsfiddle.net/Js8g6/

@R_502_1964@

关闭工具@L_489_2@后,尝试设置“.tooltip-tick”的title-attribute:

$(".tooltip-tick").attr("title","");

打开工具@L_489_2@需要标题,但不知何故,它将关闭删除.

这只是一个小小的解决办法;)

大佬总结

以上是大佬教程为你收集整理的jquery ui工具提示修改为仅在点击时工作打开和关闭一次全部内容,希望文章能够帮你解决jquery ui工具提示修改为仅在点击时工作打开和关闭一次所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。