jjzjj

closeSpan

全部标签

javascript - 如何在 document.createElement ("span"之后将文本添加到 span 中);?

我正在尝试使用函数.text()将文本写入元素范围,但出现此错误UncaughtTypeError:undefinedisnotafunction,我也试过functionappend(),innerHtml(),createTextNode()都没有成功。我做错了什么?varcloseSpan=document.createElement("span");closeSpan.setAttribute("class","sr-only");closeSpan.text("Close");//UncaughtTypeError:undefinedisnotafunction或varclo