Skip to content

Instantly share code, notes, and snippets.

@ityulkanov
Created May 23, 2018 19:13
Show Gist options
  • Save ityulkanov/9e5d62e68dfc3f99ae507d630a5f061a to your computer and use it in GitHub Desktop.
Save ityulkanov/9e5d62e68dfc3f99ae507d630a5f061a to your computer and use it in GitHub Desktop.
todo on javascript
var addButton = document.getElementById("addItem");
addButton.addEventListener('click', function(){
var inputEl = document.getElementById('toDoInput');
var input = inputEl.value;
if(!input) return;
console.log(input);
var li = document.createElement('li');
console.log(li);
var list = document.getElementById('list');
li.innerHTML = input;
li.addEventListener('click', function(e){
var elementClicked = e.target;
var style;
if(elementClicked.style.textDecoration === 'line-through')
{
style = 'none';
} else {
style = 'line-through';
}
elementClicked.style = 'text-decoration : ' + style;
})
list.appendChild(li);
inputEl.value = '';
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment