In the below example, we’ll have a table and a label. When a user clicks on a table value, it will update the label with that table value.
In the below example, we’ve wrapped our code in a document.ready() function. This is to ensure that the code only runs once the page is ready.
Next, we find a table with the id of table, and bind a click even to every td inside of that table. Once a td is clicked, we take the text inside of it and set the text of the label above it.