Treehouse: Grow your CSS skills. Land your dream job.

javascript to show / hide an image

  • # February 1, 2010 at 6:25 am

    I am using javascript to show / hide an image when a checkbox is checked. This works ok.But how do I hide the image when the page loads? I have tried using enable="false", but when I do that, the javascript fails to locate the image on the page and the image does not respond.So I set the image url to a transparent image, so the user will not see any image when the page loads, and when the user clicks the checkbox,I change the image url to the required image.Is this the best approach for this issue?

    # February 7, 2010 at 1:45 pm

    I know with jquery it would just be $("img").hide();

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.