javascript - how can i toggle b display status bettween div a an b? -


how can toggle div "b" , display status between div "a" , "b"? enter image description here

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript">     $(function(){         // how can in js ?         // mouse on , b displays         // mouse out , not on b ,2seconds b hide         // mouse out , on b , b don't hide         // mouse out b , not on a, b, 2seconds b hide     }); </script> <style type="text/css">     *{margin:0;padding:0}     .page{padding:60px;}     .a{background-color:tan;width:50px;height:50px;color:#fff}     .b{background-color:#9e0606;width:100px;height:100px;color:#fff} </style> <div class="page">     <div class="a">a</div>     <div class="b">b</div> </div> 

try this

var tout; $('.a,.b').hover(function () {     $('.b').show();     cleartimeout(tout); }, function () {     tout = settimeout(function () {         $('.b').hide();     }, 2000); }); 

demo


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -