jquery實(shí)現(xiàn)網(wǎng)站超鏈接和圖片提示效果
更新時(shí)間:2013年03月21日 14:53:01 作者:
超鏈接提示效果可以通過title實(shí)現(xiàn);圖片提示效果可以通過alt實(shí)現(xiàn),本文將會(huì)介紹下使用jquery實(shí)現(xiàn)超鏈接與圖片提示效果,感興趣的朋友們可以參考下哈
超鏈接提示效果:
<script type="text/javascript">
//<![CDATA[
$(function(){
var x = 10;
var y = 20;
$("a.tooltip").mouseover(function(e){
this.myTitle = this.title;
this.title = "";
var tooltip = "<div id='tooltip'>"+ this.myTitle +"<\/div>"; //創(chuàng)建 div 元素
$("body").append(tooltip); //把它追加到文檔中
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
}).show("fast"); //設(shè)置x坐標(biāo)和y坐標(biāo),并且顯示
}).mouseout(function(){
this.title = this.myTitle;
$("#tooltip").remove(); //移除
}).mousemove(function(e){
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
});
});
})
//]]>
</script>
圖片提示效果:
<script type="text/javascript">
//<![CDATA[
$(function(){
var x = 10;
var y = 20;
$("a.tooltip").mouseover(function(e){
this.myTitle = this.title;
this.title = "";
var imgTitle = this.myTitle? "<br/>" + this.myTitle : "";
var tooltip = "<div id='tooltip'><img src='"+ this.href +"' alt='產(chǎn)品預(yù)覽圖'/>"+imgTitle+"<\/div>"; //創(chuàng)建 div 元素
$("body").append(tooltip); //把它追加到文檔中
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
}).show("fast"); //設(shè)置x坐標(biāo)和y坐標(biāo),并且顯示
}).mouseout(function(){
this.title = this.myTitle;
$("#tooltip").remove(); //移除
}).mousemove(function(e){
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
});
});
})
//]]>
</script>
復(fù)制代碼 代碼如下:
<script type="text/javascript">
//<![CDATA[
$(function(){
var x = 10;
var y = 20;
$("a.tooltip").mouseover(function(e){
this.myTitle = this.title;
this.title = "";
var tooltip = "<div id='tooltip'>"+ this.myTitle +"<\/div>"; //創(chuàng)建 div 元素
$("body").append(tooltip); //把它追加到文檔中
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
}).show("fast"); //設(shè)置x坐標(biāo)和y坐標(biāo),并且顯示
}).mouseout(function(){
this.title = this.myTitle;
$("#tooltip").remove(); //移除
}).mousemove(function(e){
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
});
});
})
//]]>
</script>
圖片提示效果:
復(fù)制代碼 代碼如下:
<script type="text/javascript">
//<![CDATA[
$(function(){
var x = 10;
var y = 20;
$("a.tooltip").mouseover(function(e){
this.myTitle = this.title;
this.title = "";
var imgTitle = this.myTitle? "<br/>" + this.myTitle : "";
var tooltip = "<div id='tooltip'><img src='"+ this.href +"' alt='產(chǎn)品預(yù)覽圖'/>"+imgTitle+"<\/div>"; //創(chuàng)建 div 元素
$("body").append(tooltip); //把它追加到文檔中
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
}).show("fast"); //設(shè)置x坐標(biāo)和y坐標(biāo),并且顯示
}).mouseout(function(){
this.title = this.myTitle;
$("#tooltip").remove(); //移除
}).mousemove(function(e){
$("#tooltip")
.css({
"top": (e.pageY+y) + "px",
"left": (e.pageX+x) + "px"
});
});
})
//]]>
</script>
您可能感興趣的文章:
- JQuery實(shí)現(xiàn)超鏈接鼠標(biāo)提示效果的方法
- jQuery簡單實(shí)現(xiàn)title提示效果示例
- jQuery文字提示與圖片提示效果實(shí)現(xiàn)方法
- jquery實(shí)現(xiàn)簡單文字提示效果
- jQuery實(shí)現(xiàn)仿QQ空間裝扮預(yù)覽圖片的鼠標(biāo)提示效果代碼
- jquery實(shí)現(xiàn)鼠標(biāo)滑過后動(dòng)態(tài)圖片提示效果實(shí)例
- jQuery實(shí)現(xiàn)行文字鏈接提示效果的方法
- jquery刪除數(shù)據(jù)記錄時(shí)的彈出提示效果
- jQuery表單獲取和失去焦點(diǎn)輸入框提示效果的實(shí)例代碼
- jQuery實(shí)現(xiàn)的超鏈接提示效果示例【附demo源碼下載】
相關(guān)文章
使用異步controller與jQuery實(shí)現(xiàn)卷簾式分頁
這篇文章主要介紹了使用異步controller與jQuery實(shí)現(xiàn)卷簾式分頁,使用異步controller與jQuery按需加載內(nèi)容,當(dāng)用戶開始通過網(wǎng)站的內(nèi)容滾動(dòng)時(shí)進(jìn)一步加載內(nèi)容。,需要的朋友可以參考下2019-06-06
jQueryUI 拖放排序遇到滾動(dòng)條時(shí)有可能無法執(zhí)行排序的小bug及解決方案
前些日子不是在做使用Jquery-UI實(shí)現(xiàn)一次拖拽多個(gè)選中的元素操作嘛,在持續(xù)完善這個(gè)組件時(shí)遇到了一個(gè)關(guān)于拖放排序的bug。今天就著圖片和代碼重現(xiàn)一下,也順便告訴大家如何解決這個(gè)問題2016-12-12
基于jQuery+Cookie實(shí)現(xiàn)的防止刷新的在線考試倒計(jì)時(shí)
這篇文章主要介紹了基于jQuery+Cookie實(shí)現(xiàn)的防止刷新的在線考試倒計(jì)時(shí)的方法和示例,有需要的小伙伴可以參考下2015-06-06
jquery實(shí)現(xiàn)滑動(dòng)樓梯效果
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)滑動(dòng)樓梯效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
jQuery實(shí)現(xiàn)放大鏡效果實(shí)例代碼
在一些電商網(wǎng)站我們都見到使用過放大鏡來查看商品詳情,那么基于jquery代碼是如何實(shí)現(xiàn)放大鏡效果的呢?下面由腳本之家小編給大家分享jquery代碼實(shí)現(xiàn)放大鏡效果2016-03-03
jQuery插件ImageDrawer.js實(shí)現(xiàn)動(dòng)態(tài)繪制圖片動(dòng)畫(附源碼下載)
ImageDrawer.js是一款可以實(shí)現(xiàn)動(dòng)態(tài)繪制圖片動(dòng)畫的jQuery插件,接下來通過本文給大家介紹jQuery插件ImageDrawer.js實(shí)現(xiàn)動(dòng)態(tài)繪制圖片動(dòng)畫(附源碼下載),需要的朋友參考下2016-02-02
jquery實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊后展開列表內(nèi)容的導(dǎo)航欄效果
這篇文章主要介紹了jquery實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊后展開列表內(nèi)容的導(dǎo)航欄效果,通過簡單的jQuery鏈?zhǔn)讲僮鲗?shí)現(xiàn)針對頁面元素的遍歷及樣式動(dòng)態(tài)變換功能,需要的朋友可以參考下2015-09-09

