jQuery setTimeout

前端 未结 6 2386
刺人心
刺人心 2021-02-15 11:32

I\'d like to add a timeout to this tooltip code so it only displays if the mouse hovers over it after a while rather than immediately... I tried adding the setTimeout()

6条回答
  •  我寻月下人不归
    2021-02-15 12:37

    1. Use hover() instead, it's less code (and that's always good, IMO).

    Like so:

    function mcToolTip() {
        $(".mcTxb").hover(function(){
            // mouseover stuff here
            $("element").delay(3000).show(); // 3 second delay, then show
        }, function(){
            // mouseout stuff here
        });
    }
    

提交回复
热议问题