jQuery tooltip, hide after.. time

2019-03-06 04:00发布

问题:

I'm using the Flowplayer.org Tooltips and I'd like it to disappear after 4 seconds.

Here's the code for it, can anyone help?

$("#search").tooltip({ offset: [45, 170], effect: 'slide' });

Thanks :)

回答1:

Edit. Borrowed this from another Stack overflow question. It works here: http://jsfiddle.net/mmRu2/

jQuery.fn.delay = function(time,func){
    return this.each(function(){
        setTimeout(func,time);
    });
};

$('#search').delay(2000, function(){
    $('#search').fadeOut('fast');
    }
);


回答2:

After that code put

setTimeout(function() {
    $(".tooltip").fadeOut("slow");
}, 4000);


回答3:

have you tried delay?

$("#search").tooltip({ offset: [45, 170], delay: 4000, effect: 'slide' });


回答4:

None of these answers worked for me. Jamal got close, but missed the important parts.

Working code to hide a tooltip after 4seconds:

<script>
$("s.howTooltip").tooltip({
  //start when the tooltip is shown
  onShow: function () {
    //store a reference to this
    var self = this;
    //start a timeout for 4seconds
    setTimeout(function () {
      //get a reference to the tooltip and hide it.
      self.getTip().hide();
    }, 4000)
  }
})
</script>


回答5:

try the following callback... hope it will work... but i will fade to opacity 0.8... u can change the rest...

onShow: function() {
        this.getTrigger().fadeTo("slow", 0.8);
    }