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 Foundations Functions Examples

Brian CI
Brian CI
28,971 Points

Why doesn't the text input box change?

I get the console logs but the text input box does not change for me. What's wrong?

var button = document.getElementById('action');
var input = document.getElementById('text_field');

button.addEventListener('click', function () {
    console.log('clicked');
});

button.addEventListener('click', function () {
    console.log('Other click');
    input.setAttribute('value', 'Hello World');
});

1 Answer

Seems to work. See this pen

Brian CI
Brian CI
28,971 Points

Strange, works for me now too. Maybe my browser just needed to be reloaded. Thanks.

No worries. Usually the case if you expect something to work its either a typo or the browser needs a refresh :)