Javascript 在Javascript中设置锚标签的文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/3496280/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set Text of Anchor Tag In Javascript
提问by Arizona1911
How do I set the text of an anchor tag in javascript? This does not seem to work. I'm using firefox.
如何在javascript中设置锚标记的文本?这似乎不起作用。我正在使用火狐浏览器。
var link = document.createElement("a");
link.innerHtml = "Remove";
回答by Quentin
It is innerHTML. JavaScript is case sensitive.
它是innerHTML。JavaScript 区分大小写。
回答by Pekka
Property names are case sensitive in Javascript.
属性名称在 Javascript 中区分大小写。
Try
尝试
link.innerHTML = "Remove";
You will need to attach the created element to the document, too. But I assume you're doing that in the rest of your code.
您还需要将创建的元素附加到文档中。但我假设您在其余代码中这样做。
回答by brianghig
innerHtml should be innerHTML (capitalized 'HTML')
innerHtml 应该是innerHTML(大写的'HTML')
回答by Ryan Tenney
The property name is case sensitive and should be innerHTML.
属性名称区分大小写,应该是innerHTML.
回答by Mohammad Rajob
You can also use this one:
你也可以使用这个:
link.textContent= "Remove";

