gpt4 book ai didi

Javascript insideHTML 没有更新

转载 作者:行者123 更新时间:2023-12-03 09:52:36 26 4
gpt4 key购买 nike

您好,我正在尝试更新以下脚本的innerHTML

<div id="global-alert-queue" class="layout-wrapper">
<div class="alert success animate-in" role="alert">
Your submission was successful.
<button id="dismiss-alert" class="dismiss" type="button"></button>
</div>
</div>

我已经尝试过以下

var cls =document.getElementById("global-alert-queue").getElementsByClassName("animate-in")[0].innerHTML = "Change Text";

但它不起作用。

最佳答案

查看内嵌评论:

// Run when document is completely rendered and is ready to be manipulated 
document.addEventListener("DOMContentLoaded", function () {
document.querySelector("#global-alert-queue .animate-in").innerHTML = "Change Text";
});

演示:http://jsfiddle.net/tusharj/kg3cc4gw/3/

查询选择器

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors.

有关querySelector的更多信息:https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

关于Javascript insideHTML 没有更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30845667/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com