本文介绍了将innerhtml值转换为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 document.getElementById(forloop)。innerHtml
获取值。我正在文件中显示该值,其中包含一些div id为
I am getting a value by using document.getElementById("forloop").innerHtml
. And I am displaying that value in the file with some div id as
<div id="forloop"></div>.
但我想将该值分配给文件中的变量。你能问我怎么分配变量?
But I want to assign that value to a variable in the file. Can you please how can I assign to the variable?
推荐答案
var myInnerHtml = document.getElementById("forloop").innerHTML;
在大多数浏览器中,该属性名为 innerHTML
(全部大写的HTML),而不是innerHtml,所以请注意。
In most browsers, the property is named innerHTML
(with HTML in all-caps), not innerHtml, so watch for that.
这篇关于将innerhtml值转换为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!