javascript - 替换html内容的按钮
问题描述
我想替换按钮单击 div 中的某些内容。但不知何故,它不起作用。我在这里想念什么?另一个具有相同功能的脚本.getElementByID
完美运行,我在同一页面上的onload
an 中使用了它。iframe
这是我的按钮代码:
<div class="checkout_shape" id="content1">Content</div>
<div><button onclick="GoToShipping()">Click Me</button></div>
<script>
//Working function
function LoadCart(){
document.getElementById("content1").innerHTML ="<iframe src='/cart' width='100%' height='900px' frameborder='0' scrolling='yes' z-index='-5'></iframe>";
}
//Not working function
function GoToShipping(){
document.getElementById("content1").innerHTML ="<iframe src='/shipping' width='100%' height='900px' frameborder='0' scrolling='yes' z-index='7'></iframe>";
}
</script>
解决方案
推荐阅读
- java - 使用 OnClickListener() 是策略模式的一个例子吗?
- bash - BASH:按域对电子邮件地址列表进行排序
- python - 保持移动直到按键被按下(重复)
- c# - 如何将脆弱的数据(例如连接字符串从一个控制器传递到另一个控制器)
- google-apps-marketplace - 如何转让 G Suite 市场应用的所有权?
- php - htaccess 在本地主机中工作,但在 GoDaddy 中没有
- spring-boot - 没有 @PostConstruct 注释的 Spring Boot 初始化
- javascript - VueX、VUE、APOLLO - 组件未更新
- android - 当我关闭我的应用程序时,所有动态生成的内容都消失了,那么如何保存生成的内容呢?
- python - 将数据框上传到sql server中的现有表