jQueryUI tooltip Widget to show tooltip on Click

前端 未结 7 2051
自闭症患者
自闭症患者 2020-12-10 13:48

How the new jQueryUI\'s tooltip widget can be modified to open the tooltip on click event on certain element\'s on document, while the others are still showing their tootip

7条回答
  •  粉色の甜心
    2020-12-10 14:23

    This version ensures the tooltip stays visible long enough for user to move mouse over tooltip and stays visible until mouseout. Handy for allowing the user to select some text from tooltip.

    $(document).on("click", ".tooltip", function() {
        $(this).tooltip(
            { 
                items: ".tooltip", 
                content: function(){
                    return $(this).data('description');
                }, 
                close: function( event, ui ) {
                    var me = this;
                    ui.tooltip.hover(
                        function () {
                            $(this).stop(true).fadeTo(400, 1); 
                        },
                        function () {
                            $(this).fadeOut("400", function(){
                                $(this).remove();
                            });
                        }
                    );
                    ui.tooltip.on("remove", function(){
                        $(me).tooltip("destroy");
                    });
              },
            }
        );
        $(this).tooltip("open");
    });
    

    HTML

    Test
    

    Sample: http://jsfiddle.net/A44EB/123/

提交回复
热议问题