gpt4 book ai didi

javascript - HTML/javascript 自动弹出而不是点击?

转载 作者:行者123 更新时间:2023-11-27 23:49:52 25 4
gpt4 key购买 nike

所以我现在得到了这个输入,它按预期工作。但是我想创建另一个具有相同弹出窗口的页面,但是这个页面应该自动运行而不是 onclick。关于如何让它工作的任何提示?

<input type="submit" id="checkin" method="post" action="checkin.php" href = "javascript:void(1)" onclick = "document.getElementById('light1').style.display='block';document.getElementById('fade').style.display='block'" value="Check in">
<div id="light1" class="white_content">
<form id="formen" name="myForm" action="checkin.php" method="POST">'
sAlot of content
</form>
</div>

最佳答案

1) 在脚本中编写弹窗显示逻辑并去掉input标签

  <div id="light1" class="white_content">
<form id="formen" name="myForm" action="checkin.php" method="POST">'
sAlot of content
</form>
</div>


<script>
document.getElementById('light1').style.display='block';
document.getElementById('fade').style.display='block'
</script>

2)或者你也可以使用jquery在输入时触发点击事件

<input type="submit" id="checkin" method="post" action="checkin.php" href = "javascript:void(1)" onclick = "document.getElementById('light1').style.display='block';document.getElementById('fade').style.display='block'" value="Check in">
<div id="light1" class="white_content">
<form id="formen" name="myForm" action="checkin.php" method="POST">'
sAlot of content
</form>
</div>


<script>
$('#checkin').trigger('click');
</script>

关于javascript - HTML/javascript 自动弹出而不是点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27921835/

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