Try this (jsfiddle), increment the cell index by 2 each time, and use the simpler td selector:
functionmethod () {
var year = document.getElementById("year").value;
var month = document.getElementById("month").value;
var data = newDate(year, month - 1, 1);
var dataTable = document.getElementById("table");
var cells = dataTable.querySelectorAll("td");
for (var i = 0; i < cells.length; i+=2) {
var mikro = cells[i].firstChild.data.split("-");
var place = cells[i+1].firstChild.data;
console.log(mikro, place);
var yearMonth1 = mikro[0].split(".");
var yearMonth2 = mikro[1].split(".");
var data1 = newDate(yearMonth1[0], yearMonth1[1] - 1, 1);
var data2 = newDate(yearMonth2[0], yearMonth2[1] - 1, 1);
if (data1 <= data && data2 >= data) {
alert(place);
}
}
}
Share
Post a Comment
for "Javascript Html Table Parsing"
Post a Comment for "Javascript Html Table Parsing"