I have this HTML table:
var code = [];
var pname = [];
var description = [];
var size = [];
var printarea = [];
var colours = [];
var comments = [];
var cell = document.getElementsByTagName("td");
for (var i = 1; i < cell.length; i += 14) {
var c = cell[i].innerHTML;
code.push(c);
}
console.log(code);
console.log(pname);
// code = VISA01, UMBR21
// name = Sun Viscor Clip, Compact Umbrella With Steel Shaft
// description = Stylish Sun Visor Clip which holds your sunglasses in place and within reachProtects your sunglasses away from being scratchedEasy to use, sturdy, clips well and does not block your vision while driving SIZE 8 (w) x 3 (h) cm, Compact umbrella with steel shaft for a strong wind-resistant performancePush button and auto-open for a convenient and effortless openingDurable Logo printed on front and back panels; comes in several colors; can combine colors upon request
<html>
<head>
<title>Table to Array</title>
<body>
<table class="ty-table ty-qty-discount_ _table">
<tbody>
<tr>
<td>CODE</td>
<td>VISA01</td>
</tr>
<tr>
<td>NAME</td>
<td>Sun Visor Clip</td>
</tr>
<tr>
<td>DESCRIPTION</td>
<td>Stylish Sun Visor Clip which holds your sunglasses in place and within reachProtects your sunglasses away from being scratchedEasy to use, sturdy, clips well and does not block your vision while driving</td>
</tr>
<tr>
<td>SIZE</td>
<td>8 (w) x 3 (h) cm</td>
</tr>
<tr>
<td>PRINT AREA</td>
<td>4 (w) x 1 (h) cm</td>
</tr>
<tr>
<td>COLOURS</td>
<td>navy, black, red, royal, white, orange, green</td>
</tr>
<tr>
<td>COMMENTS</td>
<td></td>
</tr>
</tbody>
</table>
<table class="ty-table ty-qty-discount__table">
<tbody>
<tr>
<td>CODE</td>
<td>UMBR21</td>
</tr>
<tr>
<td>NAME</td>
<td>Compact Umbrella With Steel Shaft</td>
</tr>
<tr>
<td>DESCRIPTION</td>
<td>Compact umbrella with steel shaft for a strong wind-resistant performancePush button and auto-open for a convenient and effortless openingDurable Logo printed on front and back panels; comes in several colors; can combine colors upon request
</td>
</tr>
<tr>
<td>SIZE</td>
<td>53 (h) cm</td>
</tr>
<tr>
<td>PRINT AREA</td>
<td>20 (w) x 20 (h) cm</td>
</tr>
<tr>
<td>COLOURS</td>
<td>black, white, red, blue.please call for more colour options</td>
</tr>
<tr>
<td>COMMENTS</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
I want to extract the values from every second <td>
and put it in to an array.
For example:
code
array contains VISA01
, UMBR21
name
array contains Sun Viscor Clip
, Compact Umbrella With Steel Shaft
Can anyone please help me out?