Skip to content

Instantly share code, notes, and snippets.

@piratefsh
Created December 23, 2017 05:59
Show Gist options
  • Save piratefsh/60bc9cf0604dd17a1680a277e2a41a0f to your computer and use it in GitHub Desktop.
Save piratefsh/60bc9cf0604dd17a1680a277e2a41a0f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Interactive Features</title>
</head>
<body>
<ul id="my-list">
<li id="1">item1</li>
<li id="2">item2</li>
<li id="3">item3</li>
<li id="4">item4</li>
<li id="5">item5</li>
</ul>
<script>
function playerSelected(event){
const cellClicked = event.target.id;
}
// cell1.setAttribute('onclick', 'playerSelected()');
cell1.onclick = playerSelected;
function showListItem(event){
console.log(event.target.id)
alert('hi')
}
const list = document.getElementById('my-list');
const getTds = document.querySelector('#my-table td')
for(let i = 0; i < getTds.length; i++){
const child = getTds[i];
child.onclick = showListItem;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment