[HoverTimerライブラリ] 時間差でエレメントの内容を変更する

説明

HoverTimerライブラリで待ち時間を指定するには、hoverTimer()のオプションパラメータwaitoverとwaitoutにミリ秒を指定します。waitoverにマウスオーバー、waitoutにマウスアウトイベント発生時から処理を開始する時間を指定します。

サンプルプログラム

【HTML】
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/hoverTimer.js"></script>
<script type="text/javascript" src="js/sample.js"></script>
</head>
<body>
<h1>Hover Timerサンプル</h1>
<div id="myBlock">マウスを乗せてください</div>
</body>
</html>


【sample.js】
$(function() {
$("#myBlock").hoverTimer({
waitover : 1000,
waitout : 500,
over : function(){
$(this).text("乗った!");
},
out : function(){
$(this).text("離れた!");
}
});
});
サンプルを実行
[戻る]