jquery弹出窗口如何添加x关闭按钮?

jquery弹出窗口如何添加x关闭按钮?,jquery,Jquery,我有jquery jQuery(document).ready(function(){ jQuery('.et_pt_item_image').click(function(){ // attach a function to elements with the class "unhide" jQuery(this).closest('.et_pt_item_image').find('.hidden').show(); // Look for the closest parent

我有jquery

 jQuery(document).ready(function(){ 

jQuery('.et_pt_item_image').click(function(){ // attach a function to elements with the class "unhide"
   jQuery(this).closest('.et_pt_item_image').find('.hidden').show(); // Look for the closest parent of this item with the class "holder" and find the hidden div, show it
   jQuery(this).closest('.et_pt_item_image').find('.hidden').delay( 800 ).hide(1000); // find the same element and close after delay, take 1000 ms to close. 
});
}))

你好,我是一个弹出窗口
此时,框正在消失延迟(800)。隐藏(1000),但我想在框上有一个x按钮,只有在单击x时它才会消失。 我该怎么做

将隐藏的类定义为

隐藏{可见:无;}

现在,如果要隐藏图像,请执行$('idofthediv').addClass('hidden')并显示$('idofthediv').removeClass('hidden')

将隐藏的类定义为

隐藏{可见:无;}


现在,如果要隐藏图像,请执行$('idofthediv').addClass('hidden')并显示$('idofthediv').removeClass('hidden')

在弹出窗口中添加关闭按钮,单击关闭按钮调用下面的脚本


jQuery(this).最近('.et\u pt\u item\u image').find('.hidden').delay(800).hide(1000)

在弹出窗口中添加一个关闭按钮,点击关闭按钮调用下面的脚本


jQuery(this).最近('.et\u pt\u item\u image').find('.hidden').delay(800).hide(1000)

你可能想做这样的事情:

$('.box.close')。在('click',function()上{
$(this.parent().fadeOut();
});
.box{
位置:相对位置;
宽度:300px;
高度:200px;
边框:1px纯黑
}
.盒子,关上{
位置:绝对位置;
右:5px;
顶部:5px;
光标:指针;
}
.盒子.内胆{
填充物:5px;
}

X
这是一个弹出窗口!

您可能需要执行以下操作:

$('.box.close')。在('click',function()上{
$(this.parent().fadeOut();
});
.box{
位置:相对位置;
宽度:300px;
高度:200px;
边框:1px纯黑
}
.盒子,关上{
位置:绝对位置;
右:5px;
顶部:5px;
光标:指针;
}
.盒子.内胆{
填充物:5px;
}

X
这是一个弹出窗口!

u要在单击x按钮时消失整个框吗?在html中添加一个x,然后仅在单击x.jQuery(this).closest('.et_pt_item_image')。find('.hidden')。delay(800)。hide(1000)时触发上述代码;应仅在单击“关闭”按钮时发生。因此,删除该行并将该事件添加到按钮中,您将在单击x按钮时放置在该弹出式按钮上。要在整个框中消失吗?在html中添加一个x,然后仅在单击x.jQuery(this).closest('.et_pt_item_image')。find('.hidden')。delay(800)。hide(1000)时触发上述代码;应仅在单击“关闭”按钮时发生。因此,删除该行并将该事件添加到您将放置在popupI添加的X上的按钮,然后添加$('.hidden.close').on('click',function(){$(this.parent().fadeOut();});但是我应该把它放在geit工作的原始问题的代码中的什么地方呢?我添加了X,然后添加了$('.hidden.close')。on('click',function(){$(this.parent().fadeOut();});但是我应该把它放在我的代码中的什么地方才能让geit工作呢?我尝试了$('.hidden.close')。在('click',function(){jQuery(this).closest('.et_pt_item_image')。find('.hidden')。delay(800)。hide(1000);});但是它不工作jQuery('.hidden.close')。在('click',function(){jQuery(this).closest('.et_pt_item_image')。find('.hidden')。delay(50)。hide(500);});为我工作。抱歉,我忘了提到它是一个wordpress网站。我尝试了$('.hidden.close')。在('click',function(){jQuery(this).closest('.et_pt_item_image')。find('.hidden')。delay(800)。hide(1000);});但是它不工作jQuery('.hidden.close')。在('click',function(){jQuery(this).closest('.et_pt_item_image')。find('.hidden')。delay(50)。hide(500);});为我工作。对不起,我忘了提到这是一个wordpress网站。
<div class="et_pt_item_image"><div class="hidden"> hello Im a popup </div></div>