jquery tools系列 overlay 學(xué)習(xí)
更新時(shí)間:2009年09月06日 12:31:03 作者:
接著上次scrollable的學(xué)習(xí),今天繼續(xù)jquery tools六大功能的第四個(gè)功能——overlay的學(xué)習(xí)。
此外,tooltip還提供了一系列獲取overlay對(duì)象的方法,具體使用方式如下:
復(fù)制代碼 代碼如下:
var overlayObj=$("#overlay").overlay({api:true});
overlayObj.load();//自動(dòng)顯示overlay,(無需觸發(fā),會(huì)在頁面加載完成時(shí)自動(dòng)觸發(fā))
setTimeout(function(){overlayObj.close();},2000);//2秒后,自動(dòng)加載(出現(xiàn))的提示框隱藏
$("#overlayInfo").append("<P>overlay is opened:"+overlayObj.isOpened()+"</p>");//判斷此時(shí)是否有overlay提示框是否顯示
$("#overlayInfo").append("<p>overlay background image:"+overlayObj.getBackgroundImage()+"</p>");
$("#overlayInfo").append("<p>overlay trigger:"+overlayObj.getTrigger()+"</p>");
$("#overlayInfo").append("<p>overlay config-speed:"+overlayObj.getConf().speed+"</p>");
$("#overlayInfo").append("<p>overlay content:"+overlayObj.getContent().html()+"</p>");
overlayObj.onBeforeLoad=function(){
alert(this.getContent().attr("id"));
}
以下是overlay對(duì)象的方法說明描述:
方法 |
默認(rèn)值 | 描述 |
load() | Overlay | 打開overlay提示框的另一個(gè)方法,通過該方法可以不通過頁面事件觸發(fā)而直接通過js腳本打開overlay提示框。 |
close() | Overlay | (通過js腳本對(duì)該方法的調(diào)用)關(guān)閉彈出的overlay提示框。 |
isOpened() | boolean | 判斷當(dāng)前是否有overlay提示框被打開。如果當(dāng)前有overlay提示框已被打開,返回true。 |
getBackgroundImage() | jQuery | 將當(dāng)前overlay提示框的背景圖片作為一個(gè)jquery對(duì)象返回。 |
getContent() | jQuery | 將overlay彈出框的內(nèi)容以jquery對(duì)象的方式返回。 |
getTrigger() | jQuery | 將觸發(fā)overlay彈出框的元素以jquery對(duì)象的方式返回。 |
getConf() | Object | 獲取overlay彈出框初始化時(shí)的配置對(duì)象。 |
api | FALSE | 同配置對(duì)象中api。 |
onBeforeLoad(fn) | API | 同配置文件中onBeforeLoad屬性。 |
onLoad(fn) | API | 同配置文件中onLoad屬性。 |
onBeforeClose(fn) | API | 同配置文件中onBeforeClose屬性。 |
onClose(fn) | API | 同配置文件中onClose屬性。 |
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script src="http://flowplayer.org/tools/js/tools/1.0.2/jquery.tools.min.js" ></script>
<style><!--
body {
padding:150px 50px;
font-family:"Lucida Grande","Lucida Sans Unicode","bitstream vera sans","trebuchet ms",verdana;
}
#overlayInfo p{
color:red;
}
--></style><style >body {
padding:150px 50px;
font-family:"Lucida Grande","Lucida Sans Unicode","bitstream vera sans","trebuchet ms",verdana;
}
#overlayInfo p{
color:red;
}</style>
<link rel="stylesheet" type="text/css" />
<script type="text/javascript"><!--
$(function() {
$("button[rel]").overlay({
start:{
width: 300,
absolute: false
},
finish:{
top:10,
left:400,
absolute:false
},
speed:3000,
fadeInSpeed:3000,
closeOnClick: false,
oneInstance:false,
close:'#overlayClose',//自定義關(guān)閉按鈕
//expose: '#BAD0DB'//方式一:只以簡(jiǎn)單的背景色字符串方式設(shè)置
expose: {//方式二:以expose功能配置項(xiàng)方式設(shè)置
color: '#BAD0DB',
opacity: 0.7,
closeSpeed: 1000
},
onBeforeLoad:function(){
//alert(this.getTrigger().attr("rel")+":onBeforeLoad");//顯示該overlay提示框的觸發(fā)器rel屬性值
},
onLoad:function(){
//alert(this.getTrigger().attr("rel")+":onLoad");
},
onBeforeClose:function(){
alert(this.getTrigger().attr("rel")+":onBeforeClose");
return false;
}
});
var overlayObj=$("#overlay").overlay({api:true});
overlayObj.load();//自動(dòng)顯示overlay,(無需觸發(fā),會(huì)在頁面加載完成時(shí)自動(dòng)觸發(fā))
setTimeout(function(){overlayObj.close();},2000);//2秒后,自動(dòng)加載(出現(xiàn))的提示框隱藏
$("#overlayInfo").append("<P>overlay is opened:"+overlayObj.isOpened()+"</p>");//判斷此時(shí)是否有overlay提示框是否顯示
$("#overlayInfo").append("<p>overlay background image:"+overlayObj.getBackgroundImage()+"</p>");
$("#overlayInfo").append("<p>overlay trigger:"+overlayObj.getTrigger()+"</p>");
$("#overlayInfo").append("<p>overlay config-speed:"+overlayObj.getConf().speed+"</p>");
$("#overlayInfo").append("<p>overlay content:"+overlayObj.getContent().html()+"</p>");
overlayObj.onBeforeLoad=function(){
alert(this.getContent().attr("id"));
}
});
// --></script>
<button rel="#overlay">Open overlay</button>
<button rel="#overlay2">Other overlay</button>
<div class="overlay" id="overlay">
<h2 style="margin:10px 0">Here is my overlay</h2>
<p style="float: left; margin:0px 20px 0 0;">
<span>$$$$$$$$$$</span>
</p>
<p>
Class aptent taciti sociosqu ad litora torquent per conubia nostra,
per inceptos himenaeos. Donec lorem ligula, elementum vitae,
imperdiet a, posuere nec, ante. Quisque mattis massa id metus.
</p>
</div>
<div class="overlay" id="overlay2">
<h2 style="margin:10px 0" >Here is my another overlay</h2>
<p>
Class aptent taciti sociosqu ad litora torquent per conubia nostra,
per inceptos himenaeos. Donec lorem ligula, elementum vitae,
imperdiet a, posuere nec, ante. Quisque mattis massa id metus.
</p>
<div>
<button id="overlayClose">close</button>
</div>
</div>
<div id="overlayInfo"></div>
相關(guān)文章
jQuery News Ticker 基于jQuery的即時(shí)新聞行情展示插件
今天分享一個(gè)新聞行情的jQUery插件,可以幫助大家使用比較小的頁面區(qū)域來展示最新最重要的信息。2011-11-11Jquery chosen動(dòng)態(tài)設(shè)置值實(shí)例介紹
Jquery chosen一款選擇插件,支持檢索,多選,但不支持輸入效果,下面與大家分享下其使用示例,感興趣的朋友可以參考下,希望對(duì)大家有所幫助2013-08-08jQuery實(shí)現(xiàn)Tab菜單滾動(dòng)切換的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)Tab菜單滾動(dòng)切換的方法,實(shí)例分析了jQuery通過鼠標(biāo)事件動(dòng)態(tài)操作頁面元素切換的動(dòng)畫效果實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09推薦17個(gè)優(yōu)美新鮮的jQuery的工具提示插件
在web開發(fā)當(dāng)中,工具提示條對(duì)于完善web網(wǎng)站的用戶體驗(yàn)至關(guān)重要。title屬性通常是用來幫助用戶了解顯示鏈接的信息2012-09-09基于jQuery的遍歷同id元素 并響應(yīng)事件的代碼
寫網(wǎng)頁的時(shí)候,腳本循環(huán)的時(shí)候有很多時(shí)候都會(huì)循環(huán)出來同id的網(wǎng)頁元素,下面貼出來代碼,如何利用jQuery對(duì)這些元素進(jìn)行逐一遍歷并可響應(yīng)消息2012-06-06如何實(shí)現(xiàn)星星評(píng)價(jià)(jquery.raty.js插件)
本文主要分享了用jQuery插件jquery.raty.js實(shí)現(xiàn)星星評(píng)價(jià)功能:后臺(tái)傳數(shù)據(jù),前臺(tái)顯示星星個(gè)數(shù)的具體方法。有很好的參考價(jià)值,需要的朋友一起來看下吧2016-12-12