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

Java

Trying to update an image: Uncaught SyntaxError: missing ) after argument list

I am trying to update an image using javascript. In this test case, when the user clicks on the thumbnail the main photo above should update to be the photo that the user clicked on.

var photoToUpdate = document.getElementById("gallery-box");
var photoThumbnail = document.getElementById("testPhoto")

//When the main photo is clicked the function, updatePhoto will run
photoThumbnail.addEventListener("click",  function updatePhoto () {
        //HMTL of the main photo is replaced with a different image tag
        photoToUpdate.innerHTML = photoThumbnail.innerHTML;
    } updatePhoto() ); 
};

What I'm trying to do is say when photoThumbnail is clicked, update photoToUpdate with the innerHTML of photoThumbnail but in this iteration I get an error that says 'Uncaught SyntaxError: missing )' which I can't figure out.

In other iterations I've had other error but I'm not sure what's causing this one.

Thanks to anyone that can help.

2 Answers

Never mind everyone, I've found an alternative solution for now.

Thanks everyone.

Hey Joe,

As far as I can see, you're missing a semi-colon on line 2.

var photoToUpdate = document.getElementById("gallery-box");
var photoThumbnail = document.getElementById("testPhoto")

Notice the difference between the two lines of code?

Best,

Jacob

Thanks Jacob, I hadn't spotted that.

Unfortunately it didn't make any difference to getting it to work.

Sorry to hear that, Joe!