国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jquery自定義插件――window的實現【示例代碼】

2019-11-20 10:08:37
字體:
來源:轉載
供稿:網友

本例子實現彈窗的效果:

1、jquery.show.js

/*  * 實現功能:點擊在鼠標位置顯示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 value=顯示 type=button name=showDiv>

實現后的效果如下:

以上這篇jquery自定義插件――window的實現【示例代碼】就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沙田区| 襄垣县| 乌苏市| 农安县| 银川市| 莫力| 岳阳市| 皋兰县| 清水河县| 巴林右旗| 崇明县| 成武县| 武隆县| 津南区| 朔州市| 石家庄市| 苏尼特左旗| 永新县| 日土县| 祁阳县| 东平县| 金塔县| 湖南省| 虎林市| 红原县| 吴川市| 沾益县| 土默特左旗| 芮城县| 湟中县| 江口县| 礼泉县| 株洲市| 四平市| 龙陵县| 屏边| 郎溪县| 镇坪县| 大连市| 桐庐县| 清水河县|