最初隐藏的弹出窗口上的jQuery事件 [英] jQuery event on initially hidden popup

查看:94
本文介绍了最初隐藏的弹出窗口上的jQuery事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

jQuery(document).on('click', '.close_popup', function() {
  alert('clicked');
});

在这里,.close_popup位于div上,该页面隐藏在页面加载中,并且在单击按钮时在弹出窗口(模态对话框类型)上可见.

Here, .close_popup is on a div which is hidden on page load, and is made visible on a popup (kind of modal dialog box) on clicking a button.

由于某种原因,我没有收到警报.这里有什么提示吗?

For some reason, I'm not getting the alert fired. Any tips here?

感谢您的宝贵时间. 最好.

Thanks for your time. Best.

编辑

.close_popup类是在弹出窗口加载后动态创建的,带有关闭按钮.

The class .close_popup is dynamically created once the popup loads, with a close button.

推荐答案

在此示例中,没有特定的原因为什么您需要执行jQuery(document).on('click','.close_popup',function(){ });您应该能够摆脱jQuery('.close_popup').on('click',function(){});假设.close_popup是您的button元素,那么它也应该理清您与此链接相关的其他问题.

theres no specific reason in this example why you would need to do jQuery(document).on('click', '.close_popup', function(){}); you should be able to get away with jQuery('.close_popup').on('click', function(){}); This is presuming that the .close_popup is your button element, that should also sort out your other question that links to this one.

这篇关于最初隐藏的弹出窗口上的jQuery事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆