亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQuery鼠標(biāo)經(jīng)過圖片出現(xiàn)提示文字

Original 2016-11-08 10:47:54 413
abstract:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>reminder</title>
<script src="jquery.min.js" type="text/javascript"></script>
<style>
.box{
 position:absolute;
 border:1px solid #ccc;
 background:#333;
 padding:2px;
 color:#fff;
}
img{ border:#000 1px solid;}
</style>
</head>
  
<body>
<img src="11.jpg" />
<div class="content" style="display:none;">夏目友人帳:</div>
  
<script type="text/javascript">
$(function(){
 var x = 20;
 var y = 10;
 $("img").mouseover(function(e){ //當(dāng)鼠標(biāo)位于img上時執(zhí)行下面的函數(shù)
 var title = $(".content").text(); // 定義變量box,獲取content中的內(nèi)容
 var box = "<div class='box'>"+title+"</div>"; // 定義變量box,獲取要顯示的內(nèi)容
 $("body").append(box); //向頁面中插入變量box引入的信息
 });
 $("img").mouseout(function(){ //當(dāng)鼠標(biāo)從img移出時執(zhí)行
 $(".box").remove(); //清除頁面加載的內(nèi)容
 });
 $("img").mousemove(function(e){ //當(dāng)鼠標(biāo)在img上移動時
 $(".box").css({"top": (e.pageY+y) + "px","left": (e.pageX+x) + "px"}); //頁面中插入內(nèi)容box的位置為鼠標(biāo)的位置,再加上偏移量
 });
})
  
</script>
</body>
</html>


Release Notes

Popular Entries