JQuery slideToggle timeout

前端 未结 3 1420
盖世英雄少女心
盖世英雄少女心 2021-01-23 08:01

I have simple html page:





        
3条回答
  •  天涯浪人
    2021-01-23 08:28

    This is a very simple solution. Idea is, if you don't move your mouse over the div-container.. it will slideUp() the container itself in 2000ms (I put 2000ms, because its boring to wait 10sec).

    
    
    
        
        
    
    
        
    This is the paragraph to end all paragraphs. You should feel lucky to have seen such a paragraph in your life. Congratulations!

    [ View output ]

    1. First it will wait till the document is ready
    2. It will start the countdown to 2000ms with setTimeout() and sets it as resource to mouseover_to variable.
    3. However, if mouseover() is detected over the div then the countdown will be canceled with clearTimeout(), thanks to the help of the resource mouseover_to

提交回复
热议问题