jQuery UI Tooltip Widget auto close

2019-03-25 01:21发布

问题:

How i can automaticly close jQuery UI Tooltip Widget after 1 sec. I use following code:

var du=1000;    
$(document).tooltip(
{show:{effect:'slideDown',delay:du,duration:du/2}},
{hide:{effect:'explode',pieces:20,duration:du,delay:du/4}},
{track:true}
);

回答1:

Try:

$(document).ready(function () {
    var du = 1000;
    $(document).tooltip({
        show: {
            effect: 'slideDown'
        },
        track: true,
        open: function (event, ui) {
            setTimeout(function () {
                $(ui.tooltip).hide('explode');
            }, du);
        }
    });
});

Fiddle

Hope this helps!