[英]Bind click event to Javascript function
I have Jquery latest connected and working with other parts of application. 我有最新的Jquery连接,并与应用程序的其他部分一起工作。
0. End goal: for a modal window to appear on the screen. 0.最终目标:使模态窗口出现在屏幕上。
1. I click on a button. 1.我单击一个按钮。
2. A function runs that append a modal to body
2.运行将模式附加到
body
函数
3. With modals, in order for this modal to actually show on the screen, I need to press a button that has data-target="#EnterModalNameHere"
3.使用模态时,为了使该模态实际显示在屏幕上,我需要按下一个按钮,该按钮的
data-target="#EnterModalNameHere"
4. I make a hidden button in index.html that has the needed data-target
property. 4.我在index.html中创建一个具有所需
data-target
属性的隐藏按钮。
5. I would like to be able to click this hidden button once the function in step 2 finishes appending the modal. 5.我希望能够在步骤2中的功能完成附加模态后单击该隐藏按钮。
How can I tell Javascript "once finished appending modal, click on hidden button"? 我怎样才能告诉Javascript“附加模态后,单击隐藏按钮”?
You can create a custom Event which would be dispatch (trigger) immediately after the document is ready. 您可以创建一个自定义事件,该事件将在文档准备好后立即分派(触发)。 So, in your situation, since you aren't using a media query, you can use :
因此,根据您的情况,由于您没有使用媒体查询,因此可以使用:
setTimeout(() => { do something }, timeout);
setTimeout(() => { do something }, timeout);
. window.onload = function() { enter code here }
window.onload = function() { enter code here }
的事件监听器window.onload = function() { enter code here }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.