保留div的内容
我有一个 div,其内容名为 level0
(
)。不幸的是,我的网页中的 level0
发生了变化,我需要重用具有相同第一个值的 div
。我怎样才能实现这个目标?
编辑
我的代码:
<body onload ="init()">
<h1>Search engine bêta version</h1>
<input id="text" type="text" size="60" value="Type your keywords" />
<input type="button" value="Display the results" onclick="check();" />
<script ="text/javascript">
function check() {
var div = document.getElementById("level0"); // Here level0 takes the value of Type your keywords and I want it to stick with the first value
div.innerHTML = document.getElementById("text").value;
}
</script>
<div id="level0"> // The value I want to keep
</div>
</body>
I've got a div which has a content named level0
(<div id="level0">
). Unfortunately level0
changes in my webpage and I need the reuse the div
with the same first value.
How can I achieve this?
Edit
My code:
<body onload ="init()">
<h1>Search engine bêta version</h1>
<input id="text" type="text" size="60" value="Type your keywords" />
<input type="button" value="Display the results" onclick="check();" />
<script ="text/javascript">
function check() {
var div = document.getElementById("level0"); // Here level0 takes the value of Type your keywords and I want it to stick with the first value
div.innerHTML = document.getElementById("text").value;
}
</script>
<div id="level0"> // The value I want to keep
</div>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果想使用您显示结果的第一个“文本”,此代码可能有用
搜索引擎测试版
If want to use the first "text" for which you had displayed results this code may be useful
Search engine bêta version
下面的代码应该可以为您解决这个问题。第一次替换时,它会存储原始内容,然后每次更改 div 中的文本时,都会在其前面添加原始内容。
The code below should solve this for you. On the first time it replaces, it will store the original content, and then each time it changes the text in the div, it will prepend it with the original content.