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

Bruno Dias
Bruno Dias
10,554 Points

print function not working

I am trying to practice the print message but not sure what's wrong here:

http://jsfiddle.net/brunodd/o9ox4yhh/

2 Answers

adamdonatello
adamdonatello
27,485 Points

Hi Bruno,

You just need to adjust your function slightly. You are missing some syntax from your getElementById.

function print(message){
    var div = document.getElementById('myDiv');
    div.innerHTML = message;
}

Hope that helps!

Bruno Dias
Bruno Dias
10,554 Points

Hey Adam, Thank you for your help. I was missing the "document." Still practicing JS. It's quite difficult when you come from a design background but I'll get there. =)

Grace Kelly
Grace Kelly
33,990 Points

Hi Bruno, you're missing document. before the getElementById();, you also have mispelled getElementById() in your code