Hello,
I am having an issue with some DOM code.
The code exists within an object and is called by an ajax callback, but I don't think that is my issue, but I could be wrong, it has happened before
The below code generates the following error on the FireFox Console: "TypeError : reviewDiv is undefined".
Then it still goes ahead and correctly prints "individualReviewDiv" which is generated byI know the code does not make sense but it is to debug the issue.Code:console.log(reviewIndex);
Please advise as I am relatively new to web development and am at a stand still. Any help is appreciated.
Code:reviewChildren = mySelf.parentDiv.querySelectorAll(".individualReviewDiv"); console.log(reviewChildren.length + " reviews"); for (var i=0; reviewChildren.length; i++) { var reviewDiv = reviewChildren[i]; reviewIndex = reviewDiv.getAttribute("class"); //<----error on this line console.log(reviewIndex); }



Reply With Quote
Bookmarks