How to search the children of a HTMLDivElement?

Demo: http://jsfiddle.net/ThinkingStiff/y9K9Y/

If the <div> you’re searching for has a class, you can use getElementsByClassName():

document.getElementById( 'parentDiv' ).getElementsByClassName( 'childDiv' )[0];

If it doesn’t have a class you can use getElementsByTagName():

document.getElementById( 'parentDiv' ).getElementsByTagName( 'div' )[0];

And if it has an id you can, of course, just use getElementById() to find it no matter where it is in the DOM:

document.getElementById( 'childDiv' );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)