document.getElementById("ctiGlobalContainer").innerHtml += '<div id="ctiContentPanel" state="displayed" style="z-index: 10000;right: 0;top: 50px;height: 100%;width: 200px;position: fixed;margin: 0;"></div>'
我得到以下结果:
"undefined<div id="ctiContentPanel" state="displayed" style="z-index: 10000;right: 0;top: 50px;height: 100%;width: 200px;position: fixed;margin: 0;"></div>"
为什么是未定义的显示?并且div不包括在dom中。。。
该属性称为innerHTML
。
innerHtml
开始未定义。
=
将其转换为字符串,然后追加到字符串中。
当您将未定义的
转换为字符串时,您会得到“未定义的”
。
你那里有打字错误。请用innerHTML代替innerHtml
。Javascript没有将innerHtml
识别为其属性,这就是为什么代码中显示了未定义的
。