首頁  >  文章  >  web前端  >  JQuery實作當滑鼠停留在某區域3秒後自動執行_jquery

JQuery實作當滑鼠停留在某區域3秒後自動執行_jquery

WBOY
WBOY原創
2016-05-16 16:36:341234瀏覽

這篇文章主要介紹了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>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn