Home  >  Article  >  Web Front-end  >  js method to assign values ​​to label tags and div tags

js method to assign values ​​to label tags and div tags

高洛峰
高洛峰Original
2016-12-29 09:12:461556browse

In html, label does not have a value attribute.
Like div and most other html elements, it has innerText and innerHTML attributes
Cannot document.getElementByID("test").value="chenhuang ";
should be the following

<labelid="test"></label>
document.getElementById(test).innerText="";
<divid="test"></label>
document.getElementById(&#39;test&#39;).innerHTML="";

For more js methods of assigning values ​​to label tags and div tags, please pay attention to the PHP Chinese website for related articles!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn