jquery mobile 實(shí)現(xiàn)自定義confirm確認(rèn)框效果的簡(jiǎn)單實(shí)例
類似刪除的效果,在執(zhí)行之前,一般需要添加確認(rèn)對(duì)話框,點(diǎn)確認(rèn)的話執(zhí)行,取消按鈕就不執(zhí)行,傳統(tǒng)的js
if(confirm('確定刪除嗎?')) { //執(zhí)行代碼 }
這種效果比較丑,使用jquery mobile優(yōu)化一下
需要引用的文件:
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<link href="~/Scripts/Mobile/jquery.mobile-1.4.0.min.css" rel="stylesheet" />
<script src="~/Scripts/Mobile/jquery.mobile-1.4.0.min.js"></script>
效果如下:
function UpdateStatus() { var popupDialogId = 'popupDialog'; $('<div data-role="popup" id="' + popupDialogId + '" data-confirmed="no" data-transition="pop" data-overlay-theme="b" data-theme="b" data-dismissible="false" style="min-width:216px;max-width:500px;"> \ \ <div role="main" class="ui-content">\ <h3 class="ui-title" style="color:#fff; text-align:center;margin-bottom:15px">確認(rèn)關(guān)閉任務(wù)嗎?</h3>\ <a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b optionConfirm" data-rel="back" style="background: #1784fd;width: 33%;border-radius: 5px;height: 30px;line-height: 30px;padding: 0;font-size: .9em;margin: 0 0 0 12%;font-weight: 100;">確定</a>\ <a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b optionCancel" data-rel="back" data-transition="flow" style="background: #DBDBDB;width: 33%;border-radius: 5px;height: 30px;line-height: 30px;padding: 0;font-size: .9em;margin: 0 0 0 5%;font-weight: 100;color: #333;text-shadow: none;">取消</a>\ </div>\ </div>') .appendTo($.mobile.pageContainer); var popupDialogObj = $('#' + popupDialogId); popupDialogObj.trigger('create'); popupDialogObj.popup({ afterclose: function (event, ui) { popupDialogObj.find(".optionConfirm").first().off('click'); var isConfirmed = popupDialogObj.attr('data-confirmed') === 'yes' ? true : false; $(event.target).remove(); if (isConfirmed) { //這里執(zhí)行確認(rèn)需要執(zhí)行的代碼 } } }); popupDialogObj.popup('open'); popupDialogObj.find(".optionConfirm").first().on('click', function () { popupDialogObj.attr('data-confirmed', 'yes'); }); }
以上就是小編為大家?guī)淼膉query mobile 實(shí)現(xiàn)自定義confirm確認(rèn)框效果的簡(jiǎn)單實(shí)例全部?jī)?nèi)容了,希望大家多多支持腳本之家~
相關(guān)文章
jquery實(shí)現(xiàn)的縮略圖預(yù)覽滑塊實(shí)例
這篇文章主要介紹了jquery實(shí)現(xiàn)的縮略圖預(yù)覽滑塊,實(shí)例分析了jQuery縮略圖預(yù)覽滑塊的實(shí)現(xiàn)與使用技巧,并提供了完整的實(shí)例下載,需要的朋友可以參考下2015-06-06使用jQuery實(shí)現(xiàn)dropdownlist的聯(lián)動(dòng)效果(sharepoint 2007)
在sharepoint 2007網(wǎng)站中,使用jQuery實(shí)現(xiàn)dropdownlist的聯(lián)動(dòng)效果.2011-03-03從零開始學(xué)習(xí)jQuery (三) 管理jQuery包裝集
在使用jQuery選擇器獲取到j(luò)Query包裝集后, 我們需要對(duì)其進(jìn)行操作. 本章首先講解如何動(dòng)態(tài)的創(chuàng)建元素, 接著學(xué)習(xí)如何管理jQuery包裝集, 比如添加,刪除,切片等.2011-02-02jQuery 插件開發(fā) 其實(shí)很簡(jiǎn)單
jQuery已經(jīng)被廣泛使用,憑借其簡(jiǎn)潔的API,對(duì)DOM強(qiáng)大的操控性,易擴(kuò)展性越來越受到web開發(fā)人員的喜愛,我在社區(qū)也發(fā)布了很多的jQuery插件2009-07-07jQuery實(shí)現(xiàn)的右下角廣告窗體跟隨效果示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的右下角廣告窗體跟隨效果,涉及jQuery結(jié)合時(shí)間函數(shù)動(dòng)態(tài)操作頁面元素屬性的相關(guān)技巧,需要的朋友可以參考下2016-09-09jQuery實(shí)現(xiàn)的縱向下拉菜單實(shí)例詳解【附demo源碼下載】
這篇文章主要介紹了jQuery實(shí)現(xiàn)的縱向下拉菜單,結(jié)合實(shí)例形式分析了jQuery動(dòng)態(tài)操作頁面元素實(shí)現(xiàn)縱向下拉菜單的步驟與相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-07-07