I have an element grabbed from document.getElementById('the_id'). How can I get its next sibling and hide it? I tried this but it didn’t work:
elem.nextSibling.style.display = 'none';
Firebug error was elem.nextSibling.style is undefined.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
it’s because Firefox considers the whitespace between element nodes to be text nodes (whereas IE does not) and therefore using
.nextSiblingon an element gets that text node in Firefox.It’s useful to have a function to use to get the next element node. Something like this
then you can do