I want to create a list with check box dynamically. For that i created list item, check box,text node dynamically.
My problem is, I want to append checkbox and textnode inside List item. How to do this?
In Script:
var name=x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue;
var list = document.createElement( "li" );
var cb = document.createElement( "input" );
cb.type = "checkbox";
cb.id = "c1";
cb.value = name;
cb.checked = false;
var text = document.createTextNode( name );
In Body:
<ul id="list" >
</ul>
I want to do like,
<li><input type="checkbox">Tamil</li>
dynamically from javascript.
For that i tried like,
document.getElementById( 'list' ).appendChild(list);
document.getElementById( 'list' ).appendChild(cb);
document.getElementById( 'list' ).appendChild(text);
But it is not appended in li.
How to append these correctly?