這篇文章主要介紹了JQuery實現當鼠標停留在某區域3秒后自動執行,可以應用于很多場景
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script></head><style type="text/css">.main{width:500px;height:400px;border:dashed 1px #ccc;margin:0 auto;line-height:400px;text-align:center;}</style><body><script type="text/javascript">$(function(){$(".main").mouseover(function(){setTimeout(function(){alert('當你的鼠標移動到框體時,我會延遲3秒才顯示哦!');},3000)});})</script><div class="main">把鼠標移入此框體中,等待3秒。</div> </body></html>
新聞熱點
疑難解答