how to make this change from checkbox to label element
<html>
<body>
<script language="javascript">
window.onload=function(){
var container = document.getElementById('container'),
template = `'<li>\
<input type="checkbox">\
</li>\
<li>\
<input type="checkbox">\
</li>\
<li>\
<input type="checkbox">\
</li>';`
container.onchange = function(e) {
var event = e || window.event,
target = event.srcElement || event.target;
if( target.checked && target.parentNode.getElementsByTagName('div').length === 0 ) {
var ul = document.createElement('div');
ul.innerHTML = template;
target.parentNode.appendChild(ul);
} else {
var ul = target.parentNode.getElementsByTagName('div')[0];
target.parentNode.removeChild(ul);
}
};
}
</script>
<ul id="container">
<li>
<input type="checkbox">
</li>
<li>
<inp开发者_Python百科ut type="checkbox">
</li>
<li>
<input type="checkbox">
</li>
</ul>
</body>
</html>
i need this program to be changed from checkbox to div element. actually when a checkbox is clicked three checkbox created beneath it and so on and if the parent checkbox is unchecked all the child checkbox are removed. now i need to change this checkbox element to ordinary label element. so that when a label is clicked a three label appears beneath it.. how to do that........
精彩评论