Question

I am trying to log numbers from an HTML element without predefining a list. below is what I am currently using to attempt this but for some reason it is not adding the output to the created list element. note that the output is random. any help is appreciated.

function Log(c){
var c = document.getElementById('out').innerHTML;
var node=document.createElement("LI");
node.setAttribute("class" , f);
document.getElementById("list").appendChild(node);
node.setAttribute("value" , c);
var f = y=y++;++y
var y = 0
}

Thank you

Était-ce utile?

La solution

Change:

node.setAttribute("value" , c);

to:

node.innerHTML = c;

The value attribute is only used for user input elements (<input>, <option>, etc.).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top