jquery mobile 實(shí)現(xiàn)自定義confirm確認(rèn)框效果的簡單實(shí)例
類似刪除的效果,在執(zhí)行之前,一般需要添加確認(rèn)對話框,點(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)框效果的簡單實(shí)例全部內(nèi)容了,希望大家多多支持腳本之家~
相關(guān)文章
jQuery插件EasyUI實(shí)現(xiàn)Layout框架頁面中彈出窗體到最頂層效果(穿越iframe)
這篇文章主要介紹了jQuery插件EasyUI實(shí)現(xiàn)Layout框架頁面中彈出窗體到最頂層效果,具有穿越iframe的功能,涉及jQuery的EasyUI插件屬性操作相關(guān)技巧,需要的朋友可以參考下2016-08-08
jQuery+slidereveal實(shí)現(xiàn)的面板滑動側(cè)邊展出效果
WEB開發(fā)中有時需要在頁面上設(shè)置一個控制面板,默認(rèn)是不顯示的,當(dāng)用戶有需要時可以通過按鈕觸發(fā)調(diào)用面板展示。常見的有頁面?zhèn)冗吇雒姘逍Ч?。本文將使用jQuery插件并結(jié)合實(shí)例給大家介紹一下面板滑動展示效果。2015-03-03
jQuery實(shí)現(xiàn)可高亮顯示的二級CSS菜單效果
這篇文章主要介紹了jQuery實(shí)現(xiàn)可高亮顯示的二級CSS菜單效果,涉及基本的jquery鼠標(biāo)事件及頁面元素樣式動態(tài)改變技巧,需要的朋友可以參考下2015-09-09
前端jQuery復(fù)制文本到剪貼板功能實(shí)現(xiàn)
這篇文章主要介紹了前端如何使用jQuery實(shí)現(xiàn)點(diǎn)擊“復(fù)制”按鈕時,獲取并復(fù)制父級元素下子元素的文本HTML代碼的功能,文中給出了實(shí)現(xiàn)的詳細(xì)代碼,需要的朋友可以參考下2025-01-01
jquery實(shí)現(xiàn)簡單的表單驗(yàn)證
這篇文章主要介紹了jquery實(shí)現(xiàn)簡單的表單驗(yàn)證,思路大概是先為每一個required添加必填的標(biāo)記,用each()方法來實(shí)現(xiàn),感興趣的小伙伴們可以參考一下2015-11-11
jquery 簡單導(dǎo)航實(shí)現(xiàn)代碼
jquery簡單導(dǎo)航實(shí)現(xiàn)代碼,需要的朋友可以參考下。2009-09-09

