Created
May 23, 2018 19:13
-
-
Save ityulkanov/9e5d62e68dfc3f99ae507d630a5f061a to your computer and use it in GitHub Desktop.
todo on javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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