I am attempting to create a Calender using Jquery. But I don’t understand how to have my object print the value it contains. I tried JSON.toString() on my table data but it did not correct my issue. Maybe I am misplacing the toString method in my code?
Before toString:
// get the number of days in the month
let daysInMonth = new Date(this.displayDate.getFullYear(), this.displayDate.getMonth() + 1, 0).getDate();
// get array of days to display
let days = [];
for (let i = 1; i <= daysInMonth; i++) {
days.push(new Date(displayDate.getFullYear(), displayDate.getMonth(),i));
}
console.log(this.monthNames[this.displayDate.getMonth()] + " " + this.displayDate.getFullYear());
td = $("<td>").attr("class", "day").text(days[i].getDate());
td.append(td);
Based on this Firefox Javascript guide [object, object] is corrected using the JSON.toString() method. But when I implemented it
td = $("<td>").attr("class", "day").text(days[i].getDate());
td.append(JSON.stringify("td"));
2
Answers
You add wrong variable to method .text().
In this code: you must add
days[i].getDate()
notelem
change
td= $("<th>").text(elem);
=>td= $("<th>").text(days[i].getDate());
Line 133 :
let textNode = $(days[i].getDate());
$(days[i].getDate());
is an object,days[i].getDate();
is a int and you want this int.Then you can use your
textNode