jquery - slideDown function not working -


i have 2 div elements, when mouse enters on div1, div2 should slide down , when mouse leaves div1, div2 should slide up.

but, in function slide down function not working properly

below code:

<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script>  $(document).ready(function(){     $("#text1").mouseenter(function(){               $("#text2").slidedown("slow");      }); $("#text1").mouseleave(function(){               $("#text2").slideup("slow");      }); }); </script>  <style>  #text1 {     border:2px solid #ff0000;     width:100px;     height:100px;     text-align:center;     background-color: #9ff;     position:relative; } #text2 { display: none;     border:2px solid #ff0000;     width:100px;     height:100px;     text-align:center;     background-color: #ff0;     position:absolute;     top:8px;     left:8px;  }  </style> </head> <body>  <div id="text1">text</div> <div id="text2">video</div>  </body> </html> 

please on this. thank you.

you need use .stop() apart rest of code works. i.e.

$("#text2").stop(true).slidedown("slow"); 

stop currently-running animation on matched elements.

$(document).ready(function() {    $("#text1").mouseenter(function() {      $("#text2").stop(true).slidedown("slow");      }).mouseleave(function() {      $("#text2").stop(true).slideup("slow");    });  });
#text1 {    border: 2px solid #ff0000;    width: 100px;    height: 100px;    text-align: center;    background-color: #9ff;    position: relative;  }  #text2 {    display: none;    border: 2px solid #ff0000;    width: 100px;    height: 100px;    text-align: center;    background-color: #ff0;    position: absolute;    top: 8px;    left: 8px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  <div id="text1">text</div>  <div id="text2">video</div>


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -