【发布时间】:2022-08-19 16:15:58
【问题描述】:
我有以下html:
<h2 id=\"program-selector-modal_heading\">
<span class=\"modal-heading-before-text\"></span>
<span>Start your application to </span>
<span class=\"modal-heading-after-text\"></span>
</h2>
我正在尝试为这个特定的 id 标题更新 modal-heading-text-after 类中显示的文本:
const programSelectorModalHeadingOuter = document.getElementById(\"program-selector-modal_heading\");
programSelectorModalHeadingOuter.getElementsByClassName(\"modal-heading-after-text\").innerHTML = \"test\";
但它不起作用。有任何想法吗?我的环境设置很奇怪,我看不到错误。
-
尝试使用 document.querySelector document.querySelector(\'#program-selector-modal_heading .modal-heading-before-text\').innerHTML = \"test\"
标签: javascript