html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<table>
<tr>
<td>one</td>
<td>ten</td>
<td>six</td>
<td>two</td>
</tr>
</table>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
How do I get specific value from an array of values in javascript.
For example I have
<td>one</td>
<td>ten</td>
<td>six</td>
<td>two</td>
How do I only get six without directly using event handlers in each tag
*/
onload = init;
function init() {
var tr = document.querySelector("tr");
tr.addEventListener("click", onRowClick, false);
}
function onRowClick (e) {
console.log(e.target.innerHTML)
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run