www.webdeveloper.com
Results 1 to 1 of 1

Thread: Issue with DOM code and getAttribute

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    12

    Issue with DOM code and getAttribute

    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 by
    Code:
    console.log(reviewIndex);
    I know the code does not make sense but it is to debug the issue.

    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);
    
    			}
    Last edited by BlueGhost; 02-05-2013 at 09:05 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles