Home  >  Article  >  Web Front-end  >  jQuery focus control layer display delayed hiding method_jquery

jQuery focus control layer display delayed hiding method_jquery

WBOY
WBOYOriginal
2016-05-16 16:10:59907browse

The example in this article describes the jQuery focus control layer display delayed hiding method. Share it with everyone for your reference. The specific implementation method is as follows:

Copy code The code is as follows:







Click me


<script><br> $(document).ready(function(){<br> jQuery.focusShow({butID:'#button',divID:'#div',mouse:'over',time:'500'})<br> })<br> jQuery.extend({<br> focusShow: function(config){<br> //ps: focus control layer display, delayed hiding<br> //focusShow({butID:'button ID',divID:'container ID',mouse:'over || click',time:'time'})<br>           var butID = $(config.butID || false),<br>              divID = $(config.divID || false),<br> mouse = config.mouse || 'click',<br> Time = config.time || '500',<br> timer;<br>          function re(){$(divID).hide()}<br> switch (mouse){<br> case "click":<br>                   butID.bind({'click':function(){divID.attr('tabindex','-1');divID.focus()}});<br>             divID.bind({<br> "focus":function(){clearTimeout(timer);divID.show()},<br> "blur":function(){timer = setTimeout(re,time)}<br>                  })<br> break<br>            case "over":<br>                     $(butID,divID).each(function(){<br> $(this).bind({<br> ‘mouseover’:function(){clearTimeout(timer);divID.show()},<br> ‘mouseout’:function(){timer = setTimeout(re,time)}<br>                      })<br>                  })<br> break<br>                  default:<br> }<br> }<br> }); <br> </script>


I hope this article will be helpful to everyone’s jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn