Skip to content

Instantly share code, notes, and snippets.

@LIttleAncientForestKami
Created August 22, 2015 10:35
Show Gist options
  • Save LIttleAncientForestKami/bf33342b9671a87bdeed to your computer and use it in GitHub Desktop.
Save LIttleAncientForestKami/bf33342b9671a87bdeed to your computer and use it in GitHub Desktop.
DOM manipulation
var buildTaskList = function() {
var ol = document.getElementById('TaskList');
var list = document.createDocumentFragment();
var inputEl = function(i) {
var el = document.createElement('input');
el.setAttribute('type', 'image');
el.setAttribute('src', 'ncheck.png');
el.setAttribute('alt', 'Wykreśl');
el.setAttribute('onclick', 'RDZ.done('+i+'); this.disabled = true; return false;');
return el;
};
var counter = this.nextKey;
for(i=0;i<counter;i++) {
var item = localStorage.getItem(localStorage.key(i));
//console.log("Item "+i+" = "+item);
var li = document.createElement('li');
li.id = i;
li.innerHTML = item;
li.appendChild(inputEl(i));
list.appendChild(li);
}
ol.appendChild(list);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment