Skip to content

Instantly share code, notes, and snippets.

@JackHowa
Created February 19, 2018 01:45
Show Gist options
  • Save JackHowa/4725e1bccb918eaf24bb2ae9df683913 to your computer and use it in GitHub Desktop.
Save JackHowa/4725e1bccb918eaf24bb2ae9df683913 to your computer and use it in GitHub Desktop.
NyyrLK
<table id="card-container">
<tbody>
<tr>
<td class="card">down</td>
<td class="card">down</td>
</tr>
<tr>
<td class="card">down</td>
<td class="card">down</td>
</tr>
</tbody>
</table>
const cards = document.querySelectorAll('#card-container .card');
cards.forEach(card => {
card.addEventListener('click', handleClick);
});
function handleClick(e) {
cards.forEach(card => {
// check if this equal to itself
card === this ?
card.innerHTML="up":
card.innerHTML="down";
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment