我在单击按钮时无法调用函数。我正在使用的代码如下所示,并且在其他页面上也有效,这就是我感到困惑的原因。可能是因为此代码是使用 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/