Skip to content

Instantly share code, notes, and snippets.

@veekthoven
Created March 16, 2020 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veekthoven/d40a913dda5ee4e5a5943dea9d934092 to your computer and use it in GitHub Desktop.
Save veekthoven/d40a913dda5ee4e5a5943dea9d934092 to your computer and use it in GitHub Desktop.
<html>
<head>
<script>
setTimeout(
function() {
todos = document.querySelectorAll('li');
console.log(todos)
todos.forEach((todo, index) => {
todo.addEventListener( 'click', event => {
event.target.style = 'text-decoration: line-through';
alert( 'Item ' + (index + 1) + ': "' + event.target.innerText + '" is done!' );
} );
});
},
10
);
</script>
</head>
<body>
<ul id="todo-app">
<li class="todo">Walk the dog</li>
<li class="todo">Pay bills</li>
<li class="todo">Make dinner</li>
<li class="todo">Code for one hour</li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment