【发布时间】:2015-12-11 20:05:01
【问题描述】:
我创建了一个带有代码的 jsfiddle,该代码旨在将段落中的字符串替换为存储在按钮中的字符串。据我所知,这是正确的。但我无法让它工作。谁能指出我的错误?
<p id="arbitraryIdentification">Product information</p>
<button onclick="document.getElementByID('arbitraryIdentification').innerHTML = 'this text just replaced the original text'">text swaperizer</button>
【问题讨论】:
-
大小写很重要,是
getElementById不是getElementByID -
学习使用开发者控制台。它会给你错误。
-
并且不要在 plunker 中放入不合适的 id 名称
-
jonasnas -- 你的意思是当你快速打字时你不使用种族诽谤作为占位符?
标签: javascript string syntax output