js手機端浮層控制項,並有多種彈出小提示,相容pc端瀏覽器

來源:互聯網
上載者:User

標籤:

js dialog組件,包含alert和confirm的實現

 

本組件所有的資源均在github上可以查看原始碼 GitHub

本dialog的組件的例子請在這裡查看 demo

dialog

js dialog彈窗

用法這是內容

 

<input type="button" id="btn_dialog" value="開啟浮層"/><div id="dialog-content" style="display:none;">這是內容</div><script src="../src/jquery-1.9.1.min.js"></script><script src="../src/dialog.js"></script><script>    var dialog = new Dialog();    dialog.init({target:"#dialog-content",trigger:"#btn_dialog",mask:true,width:500,height:300,title:‘標題‘});</script>

 

或者用jquery方式調用:
   <input type="button" id="btn_dialogjquery" value="jq開啟浮層"/><div id="dialog-contentjq" style="display:none;">這是內容22</div><script src="../src/dialog-jquery.js"></script><script>    $(‘#btn_dialogjquery‘).Dialog({target:"#dialog-contentjq",mask:true,width:500,height:300,title:‘標題‘})</script>    

 

繼承類alert和confirm提示(jquery模式下):
   *html:    <input type="button" id="btn_alert" value="alert"/>    <input type="button" id="btn_alert2" value="alert定時關閉"/>    <input type="button" id="btn_confirm" value="confirm三種按鈕"/>    <input type="button" id="btn_confirmdefault" value="confirm預設"/>    *js:    $(‘#btn_alert‘).click(function(){        $.alert(‘選好商品才能上傳素材哦‘,true,function(){            alert(‘你點擊了ok‘)        })    });    $(‘#btn_alert2‘).click(function(){        $.alert(‘選好商品才能上傳素材哦‘)    });    $(‘#btn_confirm‘).click(function(){        $.confirm(‘下載全部 9 張圖片至本地相簿?<div class="confirm-title2">文字內容已複製</div>‘,[{yes:"是"},{no:‘否‘},{close:‘關閉‘}],function(type){            $.alert(‘您點擊了‘+type);            this.hide();        });    })    $(‘#btn_confirmdefault‘).click(function(){        $.confirm(‘你確定要刪除這條訊息嗎? ‘,null,function(type){            $.alert(‘您點擊了‘+type);            this.hide();        });    })

 

屬性或方法屬性trigger:
    觸發對象
target:
    彈出內容,可以為#id,或者jquery對象
mask:
    是否有遮罩層
title:
    標題
zIndex:
    z-index
closeTpl:
    關閉html(預設:<span class="ui-dialog-close js-dialog-close">x</span>)
titleTpl:
    標題html(預設:<div class="ui-dialog-title"></div>) 
方法及回調show:
    顯示彈層
hide:
    隱藏
beforeShow:function(content)
    顯示前的方法回調,content是浮層內容對象
beforeHide:function(content)
    隱藏前的方法回調,content是浮層內容對象
setPosition:function()
    設定位置置中

js手機端浮層控制項,並有多種彈出小提示,相容pc端瀏覽器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.