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 trial

JavaScript JavaScript Basics Hello, JavaScript! Your First JavaScript Program

Tao Zhang
Tao Zhang
1,535 Points

Hello, I am wondering if anyone has a simpler replacement for the command document.write("")?

This command is not recommended any more. There are some complicated procedures online for alternatives, which I don't quite understand. So if there is a simpler alternative, I am all ears. Thanks!

2 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hi there Tao Zhang ! 👋

There are definitely alternatives and better approaches but I honestly wouldn't worry about it at this stage you're currently at. You'll learn all about them very very soon and get lots of practice with them! The alternatives you saw are likely more difficult looking because you have to essentially get reference to an element on the page in which you want to manipulate.

If you're curious on how to select elements now though you can check this out:

MDN Locating DOM elements using selectors

and two common ways of adjusting the text of the selected element:

MDN innerHTML

MDN textContent

But as I said, hang in there, you'll learn all about these soon enough 👍

Tao Zhang
Tao Zhang
1,535 Points

Thanks, Travis. I'm looking forward to learning more about alternatives.