javascript - 在 Document.write() 之后调用函数时遇到问题

标签 javascript html css document.write

我在单击按钮时无法调用函数。我正在使用的代码如下所示,并且在其他页面上也有效,这就是我感到困惑的原因。可能是因为此代码是使用 Document.write(NewPage) 覆盖旧页面的新页面的一部分,其中新页面本质上是从 ajax post 返回的 php 文档?

<div class="abSpec" id="intro" style="display: block; text-align: center;"> 
    <p>Some text</p>
    <input type="button" name="proceed" id="proceed" value="Proceed"/>
</div>
<script>
$(function(){
    $("#proceed").click(function(){
        document.getElementById('intro').style.display="none";
    }
}
</script>

我不喜欢问调试问题,但我已经尝试了所有我能想到的。

谢谢。

最佳答案

document.write 只能在初始页面加载期间使用。参见 In JavaScript code after document.write() is not executed why?

关于javascript - 在 Document.write() 之后调用函数时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14544363/

相关文章:

javascript - 在不使用 addEventListener 的情况下在外部单击时隐藏 div

html - 具有交替行颜色的 Wordpress 表格并在鼠标悬停时突出显示

javascript - 如何在多行文本的文本区域中添加换行符

javascript - 如何禁用所有 div 内容

javascript - 合并与 JavaScript 中特定键值匹配的数组

Javascript 和带有变量的 href

javascript - 单击按钮打开隐藏的位置图仅适用于第一个

javascript - ReactJS + Material-UI : How to alternate colors between Material-UI <Table/>'s <TableRow/>?

html - 完全防止 Sass 包含属性

html - Ie7 随机浮点偏移