我有一个 ID 为 toptitle
的 h1
是动态创建的,我无法更改 HTML。
它将有不同的标题取决于页面。现在当它是 Profile 时,我想用 jQuery 将它更改为 New word
。
<h1 id="toptitle">Profile</h1> // Changing only when it is Profile
// to
<h1 id="toptitle">New word</h1>
注意:如果文本是Profile
,则将其更改为New word
。
最佳答案
这应该可以正常工作(使用 .text()
:
$("#toptitle").text("New word");
关于jquery - 如何使用 jQuery 更改文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6411696/