Skip to content

Instantly share code, notes, and snippets.

@lkopacz
Last active November 7, 2018 00:58
Show Gist options
  • Save lkopacz/d29d76064bd0423ba96f437561c27d65 to your computer and use it in GitHub Desktop.
Save lkopacz/d29d76064bd0423ba96f437561c27d65 to your computer and use it in GitHub Desktop.
<html>
<head>
<script>
setTimeout(
function() {
todos = document.getElementsByTagName( 'li' );
i = 0;
for (i = 0; i < todos.length; i++) {
todo = todos.item(i);
todo.addEventListener( 'click', function( evt ) {
evt.target.style = 'text-decoration: line-through';
alert( 'Item ' + ( i + 1 ) + ': "' + evt.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