School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,220 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,674 people online right now. Registration is fast and FREE... Join Now!




undefined child element

 

undefined child element

rackham

30 Jun, 2009 - 01:15 AM
Post #1

New D.I.C Head
*

Joined: 30 Jun, 2009
Posts: 3


My Contributions
Hello everyone, I have a problem with my javascript, im new to it so please bear with me.

I have a function which looks like

CODE

function mainLeftElements(){
    var containerDiv = document.getElementById('mainLeft');
    var elems = containerDiv.childNodes;
    alert(elems.length);
}


which for a div declared like so

CODE

<div id = 'mainLeft'></div>


alerts me it has a length of 1, trying to work out what the element is (thinking it might be a blank text element or something, maybe the id attribute also??) by using

CODE

elems[0].tagName


and

CODE

elems[0].id


i get confused as they both return 'undefined', so what is it?

Thanks for any help you can offer me,

Rackham

User is offlineProfile CardPM
+Quote Post


Posts in this topic
rackham   undefined child element   30 Jun, 2009 - 01:15 AM
SoLi   For me your code alerts a length of 0. Are you sur...   30 Jun, 2009 - 03:20 AM
SoLi   Here you can see a list of methods supported by te...   30 Jun, 2009 - 03:26 AM

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:28PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month