首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在javascript中用另一个div替换div?

如何在javascript中用另一个div替换div?
EN

Stack Overflow用户
提问于 2016-05-20 21:14:40
回答 6查看 43.7K关注 0票数 4

如何在javascript中用另一个div替换div?

这就是我所拥有的:

代码语言:javascript
复制
<div id="main_place">
main
</div>

<button onclick="show(operation1)">Replace to operation 1</button>
<button onclick="show(operation2)">Replace to operation 2</button>
<button onclick="show(operation3)">Replace to operation 3</button>


<div id=operation1 style=“display:none”>
Some textboxes and text
</div>

<div id=operation2 style=“display:none”>
Again some textboxes and text
</div>

<div id=operation3 style=“display:none”>
And again some textboxes and text
</div>

<script>
function show(param_div_id){
        document.getElementById('main_place').innerHTML = Here should be div from param;
        }
</script>

有没有可能在没有jquery的情况下完成呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37347690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档