CMS2
CMS2

Reputation: 5

list created with javascript is not displaying list data from html element

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

Upvotes: 0

Views: 35

Answers (1)

Barmar
Barmar

Reputation: 781751

Change:

node.setAttribute("value" , c);

to:

node.innerHTML = c;

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

Upvotes: 1

Related Questions