How to get li tag value which is in ul tag using getElementById
4 answers
You need to read the attribute value since the HTMLLiElement does not have a value property:
document.getElementById("repoFolder").getAttribute("value"); And since the value attribute is not specified in the specification of the li tag, it is better to use the data attribute (with .getAttribute("data-value") ):
<li id="repoFolder" data-value="abc">Lazy Node</li> Then the HTML will be valid and the IDE will not complain about unknown attributes.
Check out the demo below.
+3