The settimeoutjquery selector solution is not supported in setTimeout.
Today, when I wrote a js latency event, I found that the $ (this) of jquery In the setTimeout method did not work. Various tests, the final conclusion is that the setTimeout does not support jquery selector. So I consulted a professional on jquery development on QQ and immediately solved the problem. I will record it here.
Below is the js code used by the author for latency processing:
$('.dl_select dt').hover( function(){ clearTimeout(t3); $(this).siblings('dd').css({'display':'block','cursor':'pointer'}); }, function(){ t2=setTimeout(function(){$(this).siblings('dd').css({'display':'none'});},300); } ); $('.dl_select dd').hover( function(){ clearTimeout(t2); $(this).css({'display':'block','cursor':'pointer'}); }, function(){ t3=setTimeout(function(){$(this).css({'display':'none'});},200); } );
Pay attention to the Code in setTimeout in the above Code. If the Code is not in this method, it is no problem, but the above situation will report an error. As for the reason, the author does not understand it now. It's okay to change it to the following after the netizens click it. The method is clever. The following is the correct code:
$('.dl_select dt').hover( function(){ clearTimeout(t3); $(this).siblings('dd').css({'display':'block','cursor':'pointer'}); }, function(){ var $this=$(this).siblings('dd'); t2=setTimeout(function(){$this.css({'display':'none'});},300); } ); $('.dl_select dd').hover( function(){ clearTimeout(t2); $(this).css({'display':'block','cursor':'pointer'}); }, function(){ var $this=$(this); t3=setTimeout(function(){$this.css({'display':'none'});},200); } );
The above is all the content of this article. I hope you will like it.