const chapterButtons = $(".chapter-button");
chapterButtons.each(() => {
$(this).click(() => {
window.location.href = "reading-page.html";
let chptNum = parseInt($(this).attr("id"));
sessionStorage.setItem("chptNum", chptNum);
})
})
The $(this).attr("id")
is undefined for all elements even though each element certainly has an id along with the .chapter-button class. I think there is some issue with using $(this) and it is not what I think it is. However, I'm not sure what it should be. I couldn't find someone else having this exact same issue.
Any help would be much appreciated!