gpt4 book ai didi

javascript - Jquery 弹出框

转载 作者:行者123 更新时间:2023-11-30 10:36:55 25 4
gpt4 key购买 nike

我是 JavaScript 和 Jquery 的新手。我在网上搜索了 Jquery 弹出示例。我希望消息说“我们的网站尚未完成,但请随意浏览我们拥有的内容。”我将包括我找到的代码示例,但它看起来真的很奇怪。我不确定函数的名称是什么以及如何使用 window.onload = function(); 执行它。代码。我还想要一个关闭文本框的按钮“关闭”。它应该是这样的:http://demo.tutorialzine.com/2010/12/better-confirm-box-jquery-css3/

这是第一部分:

    (function($){

$.confirm = function(params){

if($('#confirmOverlay').length){
// A confirm is already shown on the page:
return false;
}

var buttonHTML = '';
$.each(params.buttons,function(name,obj){

// Generating the markup for the buttons:

buttonHTML += '<a href="#" class="button '+obj['class']+'">'+name+'<span></span></a>';

if(!obj.action){
obj.action = function(){};
}
});

var markup = [
'<div id="confirmOverlay">',
'<div id="confirmBox">',
'<h1>',params.title,'</h1>',
'<p>',params.message,'</p>',
'<div id="confirmButtons">',
buttonHTML,
'</div></div></div>'
].join('');

$(markup).hide().appendTo('body').fadeIn();

var buttons = $('#confirmBox .button'),
i = 0;

$.each(params.buttons,function(name,obj){
buttons.eq(i++).click(function(){

// Calling the action attribute when a
// click occurs, and hiding the confirm.

obj.action();
$.confirm.hide();
return false;
});
});
}

$.confirm.hide = function(){
$('#confirmOverlay').fadeOut(function(){
$(this).remove();
});
}

})(jQuery);

这是第二部分:

$(document).ready(function(){

$('.item .delete').click(function(){

var elem = $(this).closest('.item');

$.confirm({
'title' : 'Delete Confirmation',
'message' : 'You are about to delete this item. <br />It cannot be restored at a later time! Continue?',
'buttons' : {
'Yes' : {
'class' : 'blue',
'action': function(){
elem.slideUp();
}
},
'No' : {
'class' : 'gray',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
});

});

});

$(markup).hide().appendTo('body').fadeIn();

var buttons = $('#confirmBox .button'),
i = 0;

$.each(params.buttons,function(name,obj){
buttons.eq(i++).click(function(){

// Calling the action attribute when a
// click occurs, and hiding the confirm.

obj.action();
$.confirm.hide();
return false;
});
});
}

$.confirm.hide = function(){
$('#confirmOverlay').fadeOut(function(){
$(this).remove();
});
}

})(jQuery);

编辑:我收到了在加载时显示的消息。我把第二部分的代码改成了

$('.item .delete').ready(function(){

最佳答案

对话窗口之类的,请看这张图:

enter image description here

请检查这个例子:http://www.ericmmartin.com/projects/simplemodal/

有各种类型的pop模型:http://www.ericmmartin.com/projects/

和编码示例:http://www.ericmmartin.com/projects/simplemodal/#examples

关于javascript - Jquery 弹出框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13466523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com