Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSean Fallon
8,516 PointsI notice .nextElementSibling is read only and you can't color text.
I don't understand why this is read only. What if I want to color or style the text of the next element? How would I select that element?
3 Answers
Justin Kao
5,724 PointsIf you go to MDN to read Element.children, you will see that is also read only. But the teacher use it to manipulate the children property all the time.
Read only means that you CANNOT assign directly
You still can do OOP like code below.
textNode.nextElementSibling.style.color = 'red'
Justin Kao
5,724 Pointsdude, please try it yourself. It CANNOT be re-assign, but you can manipulate its property.
Sean Fallon
8,516 PointsI think there is a misunderstanding. That did not answer my question. My question was what if I want to color the next sibling. Clearly I can't use .nextElementSibling because its read only. How would I go about doing that?
Sean Fallon
8,516 PointsI read the MDN and I've created several jsfiddles testing it. I got it to work now. Still a little confused on how and when something is not manipulatable.
Justin Kao
5,724 PointsI think you will get improved after practice and experience. read MDN and test out. I'm also on this way of endless learning.