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

來源:互聯網
上載者:User

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

   這篇文章主要介紹了js相容pc端瀏覽器並有多種彈出小提示的手機端浮層控制項,執行個體分析了javascript多種彈出層效果的實現技巧,非常具有實用價值,需要的朋友可以參考下

  完整執行個體代碼點擊此處本站下載。

  用法

  ?

1

2

3

4

5

6

7

8

<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方式調用:

  ?

1

2

3

4

5

6

<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:

  ?

1

2

3

4

<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:

  ?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

$('#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(預設:x)

  titleTpl:

  標題html(預設:

 

)

 

  方法及回調:

  show:

  顯示彈層

  hide:

  隱藏

  beforeShow:function(content)

  顯示前的方法回調,content是浮層內容對象

  beforeHide:function(content)

  隱藏前的方法回調,content是浮層內容對象

  setPosition:function()

  設定位置置中

  希望本文所述對大家的javascript程式設計有所協助。

聯繫我們

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