JavaScript通過(guò)mouseover()實(shí)現(xiàn)圖片變大效果的示例
實(shí)例如下所示:
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>圖片提示</title> <!--jQuery --> <script src="../jquery.min.js"type="text/javascript"></script> <style type="text/css"> body{ margin:0; padding:40px; background:#fff; font:80% Arial, Helvetica, sans-serif; color:#555; line-height:180%; } img{border:none;} ul,li{ margin:0; padding:0; } li{ list-style:none; float:left; display:inline; margin-right:10px; border:1px solid #AAAAAA; } /* tooltip */ #tooltip{ position:absolute; border:1px solid #ccc; background:#333; padding:2px; display:none; color:#fff; } </style> <script type="text/javascript"> $(document).ready(function(){ var x=1,y=1; var myHref; $("a[class=tooltip]").mouseover(function(e){//鼠標(biāo)懸停的時(shí)候 myHref=this.href;//獲取大圖片 var $div=$("<div id='tooltip'><img src='"+myHref+"'></img></div>");//創(chuàng)建一個(gè)div $("body").append($div);//把div添加到body中 $("#tooltip").css({ top:e.pageY+y+"px", left:e.pageX+x+"px" }).show("slow"); }).mouseout(function(e){//鼠標(biāo)移開的時(shí)候 $("#tooltip").remove(); }).mousemove(function(e){//鼠標(biāo)移動(dòng)的時(shí)候 $("#tooltip").css({ top:e.pageY+y+"px", left:e.pageX+x+"px" }).show("slow"); }) }); </script> </head> <body> <ul> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> <li><a href="02121.png" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="tooltip" ><img src="02121.png" /></a></li> </ul> <br/><br/><br/><br/> <br/><br/><br/><br/> </body> </html>
以上這篇JavaScript通過(guò)mouseover()實(shí)現(xiàn)圖片變大效果的示例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
js調(diào)試工具console.log()方法查看js代碼的執(zhí)行情況
以往都是使用alert的方式查看js代碼的執(zhí)行情況,今天看到有朋友使用console.log函數(shù)打印輸出函數(shù),變量,對(duì)象,下邊就console.log的使用情況進(jìn)行記錄2014-08-08javascript AutoScroller 函數(shù)類
javascript AutoScroller 自動(dòng)滾動(dòng)類代碼,學(xué)習(xí)類的朋友可以參考下。2009-05-05JavaScript 動(dòng)態(tài)將數(shù)字金額轉(zhuǎn)化為中文大寫金額
JavaScript 將數(shù)字金額轉(zhuǎn)化為中文大寫金額的函數(shù)2009-05-05JavaScript中改變this指向的三種方式總結(jié)
this?指向的值是可以通過(guò)手動(dòng)方式去改變的,比如call、bind、apply方法,本文主要為大家介紹了這三種方式的具體實(shí)現(xiàn)步驟,需要的可以參考下2023-12-12基于layui實(shí)現(xiàn)高級(jí)搜索(篩選)功能
這篇文章主要為大家詳細(xì)介紹了基于layui實(shí)現(xiàn)高級(jí)搜索、篩選功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-07-07JavaScript基于DOM操作實(shí)現(xiàn)簡(jiǎn)單的數(shù)學(xué)運(yùn)算功能示例
這篇文章主要介紹了JavaScript基于DOM操作實(shí)現(xiàn)簡(jiǎn)單的數(shù)學(xué)運(yùn)算功能,涉及javascript節(jié)點(diǎn)操作、元素遍歷及數(shù)學(xué)運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下2017-01-01js+css實(shí)現(xiàn)超簡(jiǎn)潔的二級(jí)下拉菜單效果代碼
這篇文章主要介紹了js+css實(shí)現(xiàn)超簡(jiǎn)潔的二級(jí)下拉菜單效果代碼,通過(guò)非常簡(jiǎn)單的JavaScript遍歷頁(yè)面元素及動(dòng)態(tài)設(shè)置樣式達(dá)到二級(jí)下拉菜單的效果,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09