jQuery實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊彈出漸變層的方法
更新時間:2015年07月09日 09:42:52 投稿:goldensun
這篇文章主要介紹了jQuery實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊彈出漸變層的方法,jQuery是當(dāng)下最具人氣的JavaScript庫,需要的朋友可以參考下
彈出層在實(shí)際應(yīng)用中我們經(jīng)常會碰到大量的彈出層效果,下面我來做一個基于jquery的簡單的彈出層效果實(shí)例,各位朋友有興趣可參考。
效果代碼如下

在彈出層中下面是核心代碼
<script type="text/javascript">
// 漸變彈出層
$(document).ready(function(){
var speed = 600;//動畫速度
$("#race a").click(function(event){//綁定事件處理
event.stopPropagation();
var offset = $(event.target).offset();//取消事件冒泡
$("#racePop").css({ top:offset.top + $(event.target).height() + "px", left:offset.left });//設(shè)置彈出層位置
$("#racePop").show(speed);//動畫顯示
});
$(document).click(function(event) { $("#racePop").hide(speed) });//單擊空白區(qū)域隱藏
$("#racePop").click(function(event) { $("#racePop").hide(speed) });//單擊彈出層則自身隱藏
});
</script>
完整實(shí)例
<!-- 漸變彈出層 -->
<div id="race"><a href="#">點(diǎn)擊</a></div>
<div id="racePop" class="raceShow">這里是彈出層效果</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
// 漸變彈出層
$(document).ready(function(){
var speed = 600;//動畫速度
$("#race a").click(function(event){//綁定事件處理
event.stopPropagation();
var offset = $(event.target).offset();//取消事件冒泡
$("#racePop").css({ top:offset.top + $(event.target).height() + "px", left:offset.left });//設(shè)置彈出層位置
$("#racePop").show(speed);//動畫顯示
});
$(document).click(function(event) { $("#racePop").hide(speed) });//單擊空白區(qū)域隱藏
$("#racePop").click(function(event) { $("#racePop").hide(speed) });//單擊彈出層則自身隱藏
});
</script>
<style>
body{margin:0 auto;font:12px/1.5 tahoma,arial,5b8b4f53;color:#828282;background:#fff}
body,h1,h2,h3,h4,h5,h6,p,ul,li,dl,dt,dd{padding:0;margin:0;}
li{list-style:none;}img{border:none;}em{font-style:normal;}
a{color:#555;text-decoration:none;outline:none;blr:this.onFocus=this.blur();}
a:hover{color:#000;text-decoration:underline;}
body{font-size:12px;font-family:Arial,Verdana, Helvetica, sans-serif;word-break:break-all;word-wrap:break-word;}
.clear{height:0;overflow:hidden;clear:both;}
/* 漸變彈出層 */
#race{display:block;width:200px;height:50px;line-height:50px;text-align:center;background:#CCC;border:#555 1px solid;margin:10px auto}
.raceShow{background-color:#f1f1f1;border:solid 1px #ccc;position:absolute;display:none;width:300px;height:100px;padding:5px;font-size:12px;}
</style>
您可能感興趣的文章:
- jquery鼠標(biāo)放上去顯示懸浮層即彈出定位的div層
- Jquery利用mouseenter和mouseleave實(shí)現(xiàn)鼠標(biāo)經(jīng)過彈出層且可以點(diǎn)擊
- Jquery中國地圖熱點(diǎn)效果-鼠標(biāo)經(jīng)過彈出提示層信息的簡單實(shí)例
- 使用jquery實(shí)現(xiàn)鼠標(biāo)滑過彈出更多相關(guān)信息層附源碼下載
- jQuery Dialog 彈出層對話框插件
- 基于jquery的模態(tài)div層彈出效果
- jquery實(shí)現(xiàn)居中彈出層代碼
- jQuery彈出層始終垂直居中相對于屏幕或當(dāng)前窗口
- jQuery拖動div、移動div、彈出層實(shí)現(xiàn)原理及示例
- JQuery彈出層示例可自定義
- jQuery實(shí)現(xiàn)鼠標(biāo)移到某個對象時彈出顯示層功能
相關(guān)文章
jQuery實(shí)現(xiàn)打開網(wǎng)頁自動彈出遮罩層或點(diǎn)擊彈出遮罩層功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)打開網(wǎng)頁自動彈出遮罩層或點(diǎn)擊彈出遮罩層功能,涉及jQuery事件響應(yīng)及窗口元素屬性的相關(guān)操作技巧,需要的朋友可以參考下2017-10-10
jQuery.form.js插件不能解決連接超時(timeout)的原因分析及解決方法
jQuery.form.js是一個form插件,支持ajax表單提交和ajax文件上傳。最近在使用jquery.form.js提交包含文件的表單時,當(dāng)碰上網(wǎng)速較慢時,而我們又設(shè)置了timeout時我們的頁面會死在這里,怎么回事呢,下面腳本之家小編給大家解答下2016-10-10
Struts2+jquery.form.js實(shí)現(xiàn)圖片與文件上傳的方法
這篇文章主要介紹了Struts2+jquery.form.js實(shí)現(xiàn)圖片與文件上傳的方法,結(jié)合實(shí)例形式詳細(xì)分析了jquery.form.js插件實(shí)現(xiàn)前臺圖片上傳提交及Struts2進(jìn)行后臺處理的相關(guān)步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-05-05
jQuery EasyUI API 中文文檔 可調(diào)整尺寸
jQuery EasyUI API 中文文檔 可調(diào)整尺寸,學(xué)習(xí)jQuery EasyUI的朋友可以參考下。2011-09-09
jquery鼠標(biāo)滑過提示title具體實(shí)現(xiàn)代碼
這篇文章介紹了jquery鼠標(biāo)滑過提示title具體實(shí)現(xiàn)代碼,有需要的朋友可以參考一下2013-08-08

