jquery自定義插件開發(fā)之window的實現(xiàn)過程
本例子實現(xiàn)彈窗的效果:如果親感覺效果還不錯,請繼續(xù)往下閱讀。
1、jquery.show.js
/* * 開發(fā)者:lzugis * 開發(fā)時間:2014年6月10日 * 實現(xiàn)功能:點擊在鼠標位置顯示div * 版本序號:1.0 */ (function($){ $.fn.showDIV = function(options){ var defaults = {}; var options = $.extend(defaults, options); var showdiv=$(this); var close, title, content; close=$(" "); title=$(" "); content=$(" "); showdiv.html(""); showdiv.append(close); showdiv.append(title); showdiv.append(content); close.html("X"); title.html(options.title); content.html(options.content); showdiv.css("display","block"); showdiv.css("position","absolute"); showdiv.css("left",($(window).width()-options.width)/2+"px"); showdiv.css("top",($(window).height()-options.height)/2+"px"); showdiv.css("width",options.width); showdiv.css("height",options.height); close.bind("click",function(){ showdiv.css("display","none"); }); }; })(jQuery);
2、jquery.showdiv.css
body div { font-size:12px; text-align:center; } #container { background-color:#CCC; border:1px solid #000; width:1024px; height:600px; } #showdiv { background-color:#FF0; width:100px; height:100px; display:none; z-index:99; } .title { padding:10px; background:#F39; font-weight:bold; text-align:center; color:#FFF; } .close { margin:5px; position:absolute; right:0px; top::0px; padding:5px; color:#000; background:#FFF; } .close:hover { cursor:pointer; background:#CCC; } .content { text-align:left; padding:10px; }
3、demo.html
<script type="text/javascript" src="jquery/jquery.min.js"></script> <script type="text/javascript" src="jquery/jquery.showdiv.js"></script> <script type="text/javascript"> $(document).ready(function (){ $('#show').bind("click", function(evt){ var showdiv = $('#showdiv').showDIV({ width:400, height:200, title:"我不是黃蓉", content:"我不是黃蓉<br>我不會武功<br>我只要靖哥哥<br>完美的愛情" }); }); }); </script> <input id="show" name="showDiv" value="顯示" type="button">
以上所述是小編給大家介紹的jquery自定義插件開發(fā)之window的實現(xiàn)過程,希望對大家有所幫助!同時也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
使用jQuery判斷Div是否在可視區(qū)域的方法 判斷div是否可見
這篇文章主要介紹了使用jQuery判斷Div是否在可視區(qū)域的方法 判斷div是否可見2016-02-02jQuery插件echarts實現(xiàn)的去掉X軸、Y軸和網(wǎng)格線效果示例【附demo源碼下載】
這篇文章主要介紹了jQuery插件echarts實現(xiàn)的去掉X軸、Y軸和網(wǎng)格線效果,結(jié)合實例形式分析了echarts插件繪制表格圖及圖形相關(guān)屬性設(shè)置操作技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2017-03-03jquery簡單瀑布流實現(xiàn)原理及ie8下測試代碼
可以將分頁獲取的內(nèi)容依次填入四個div中,瀑布流的分頁可以以多頁(比如5頁)為單位二次分頁,這樣可以減少后臺算法的復(fù)雜度;測試環(huán)境:ie8 ff13.0.1 chrome22有興趣的朋友可以了解下2013-01-01基于jquery實現(xiàn)滾輪放大縮小圖片的函數(shù)代碼
這篇文章主要介紹了基于jquery實現(xiàn)滾輪放大縮小圖片的函數(shù)代碼,需要的朋友可以參考下2023-05-05