jquery tooltip set timeout

前端 未结 1 1330
别跟我提以往
别跟我提以往 2021-01-06 18:15

I want to show a tooltip which will disappear after 3 seconds time.

How should I modify my code? seems commented code will not work:

http://jsfiddle.net/sMJ2

相关标签:
1条回答
  • 2021-01-06 18:35

    You can do it like this:

    $(function () {
        $('#mytooltip').tooltip();
    
        $('#mytooltip').tooltip({
            open: function (e, o) {
                $(o.tooltip).mouseover(function (e) {
                    $('#mytooltip').tooltip('close');
                });
                $(o.tooltip).mouseout(function (e) {});
            },
            close: function (e, o) {},
            show: {
                duration: 800
            }
        });
    
        $('#mytooltip').tooltip('open');
        setTimeout(function () {
            $('#mytooltip').tooltip('close'); //close the tooltip
        }, 3000); //but invoke me after 3 secs
    });
    

    Fiddle.

    0 讨论(0)
提交回复
热议问题