【发布时间】:2011-05-05 18:41:29
【问题描述】:
我正在开发一个完全基于 Javascript 的网站:您加载网站,然后所有页面都由 Javascript 拉入。
这就是我所拥有的:
<span id="deathWormButton">Death Worm</span>
<div id="pageContent">
<p>Thanks for taking the time to view my portfolio!</p>
<p>Placeholder content</p>
<p>Placeholder content</p>
<p>Placeholder content</p>
<p>Placeholder content</p>
</div>
<div id="DeathWormPage" class="page">
<p>Thanks for taking the time to view my portfolio!</p>
<p>Placeholder content</p>
<p>Placeholder content</p>
<p>Placeholder content</p>
<p>Placeholder content</p>
</div>
这是我的 jQuery:
$(document).ready(function()
{
$(".page").hide();
});
$("#deathWormButton").click(function()
{
$("#pageContent").innerHTML = $("#DeathWormPage").innerHTML;
});
但它不起作用! (查看here)
那么当点击deathWormButton 时,如何将div id="DeathWormPage" 中的内容复制到div id="pageContent" 中?
【问题讨论】:
-
我只是好奇你为什么要这样做。
$("#deathWormButton").click(function() { $("#DeathWormPage").show(); });不会做你需要的吗? -
是的,触摸。它可能看起来也会更好。也许我会选择这个......