欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于JQuery的一個(gè)簡(jiǎn)單的鼠標(biāo)跟隨提示效果

 更新時(shí)間:2010年09月23日 17:38:31   作者:  
代碼很簡(jiǎn)單主要是用到了JQuery的三個(gè)事件mouseover,mouseout,mousemove.

1.效果如圖

  

2.實(shí)現(xiàn)思路

  1 鼠標(biāo)移入標(biāo)題(這里是<a>標(biāo)簽)

    創(chuàng)建一個(gè)div,div的內(nèi)容為鼠標(biāo)位置的文本

    將創(chuàng)建好的div加到文檔中

    為提示層設(shè)置位置

  2 鼠標(biāo)移出標(biāo)題

    移除div

  3 當(dāng)鼠標(biāo)在標(biāo)題內(nèi)移動(dòng)時(shí)

    同樣添加div效果

3.JQuery實(shí)現(xiàn)代碼

復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<style type="text/css">
body
{
font-size:12px;
}
a
{
text-decoration:none;
}
a:hover
{
color:#CC0000;
}
#main
{
margin:100px auto;
width:350px;
height:150px;
border:solid #aaa 1px;
}
.tr_color{
background-color:#aaa;
}
</style>
<script src="../JQuery/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("tr:even").addClass("tr_color");
$("#tb a").mouseover(function(e){
var toolTip = "<div id='tooltip' width='100px' height='12px' style='position:absolute;border:solid #aaa 1px;background-color:#F9F9F9'>" + $(this).html() + "</div>";
$("body").append(toolTip);
$("#tooltip").css({
"top" :e.pageY + "px",
"left" :e.pageX + "px"
});
$("#tb a").mouseout(function(){
$("#tooltip").remove();
});
$("#tb a").mousemove(function(e){
$("#tooltip").css({
"top" :(e.pageY+5) + "px",
"left" :(e.pageX+2) + "px"
});
});
//alert("Y:" + e.pageY + "X:" + e.pageX);
});
});
</script>
<body>
<div id="main">
<h5>JQuery--鼠標(biāo)跟隨提示</h5>
<table id="tb" width="100%">
<tr>
<td><a href="#">中秋快樂(lè)11</a></td>
<td><a href="#">中秋快樂(lè)12</a></td>
</tr>
<tr>
<td><a href="#">中秋快樂(lè)21</a></td>
<td><a href="#">中秋快樂(lè)22</a></td>
</tr>
<tr>
<td><a href="#">中秋快樂(lè)31</a></td>
<td><a href="#">中秋快樂(lè)32</a></td>
</tr>
<tr>
<td><a href="#">中秋快樂(lè)41</a></td>
<td><a href="#">中秋快樂(lè)42</a></td>
</tr>
<tr>
<td><a href="#">中秋快樂(lè)51</a></td>
<td><a href="#">中秋快樂(lè)52</a></td>
</tr>
<tr>
<td><a href="#">中秋快樂(lè)61</a></td>
<td><a href="#">中秋快樂(lè)62</a></td>
</tr>
</table>
</div>
</body>
</html>

代碼很簡(jiǎn)單主要是用到了JQuery的三個(gè)事件mouseover,mouseout,mousemove.

相關(guān)文章

最新評(píng)論