jquery自訂外掛程式開發之window的實現過程_jquery

來源:互聯網
上載者:User

本例子實現彈窗的效果:如果親感覺效果還不錯,請繼續往下閱讀。

1、jquery.show.js

/** 開發人員:lzugis* 開發時間:2014年6月10日* 實現功能:點擊在滑鼠位置顯示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自訂外掛程式開發之window的實現過程,希望對大家有所協助!同時也非常感謝大家對雲棲社區網站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.