gpt4 book ai didi

更改段落时的 Javascript 错误

转载 作者:行者123 更新时间:2023-11-30 12:32:12 25 4
gpt4 key购买 nike

所以我试图让一个页面为每个按下的按钮显示不同的段落。但是,我不断收到一些错误,其中按钮无法正确运行该功能。例如

function examplefunction() {
document.getElemtentById("paragraphtobechanged").innerHTML = "When I put more "" it fails in other words it will not write this part."
}
<button onclick="examplefunction()">Change Paragraph</button>
<p id="paragraphtobechanged"></p>

最佳答案

应该是:

function examplefunction() {
document.getElemtentById("paragraphtobechanged").innerHTML = "When I put more \"\" it fails in other words it will not write this part."
}

您需要转义双引号。或者你可以这样做:

function examplefunction() {
document.getElemtentById("paragraphtobechanged").innerHTML = 'When I put more "" it fails in other words it will not write this part.'
}

关于更改段落时的 Javascript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27365900/

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