javascript get child by id
Posted
by Senica Gonzalez
on Stack Overflow
See other posts from Stack Overflow
or by Senica Gonzalez
Published on 2010-05-24T17:57:38Z
Indexed on
2010/05/24
18:01 UTC
Read the original article
Hit count: 281
JavaScript
<div onclick="test(this)">
Test
<div id="child">child</div>
</div>
I want to change the style of the child div when the parent div is clicked. How do I reference it? I would like to be able to reference it by ID as the the html in the parent div could change and the child won't be the first child etc.
function test(el){
el.childNode["child"].style.display = "none";
}
Something like that, where I can reference the child node by id and set the style of it.
Thanks.
© Stack Overflow or respective owner