0

have a very basic page that I am working on that contains thumbnail images and a main image. When the thumbnail images are clicked I am using document.getElementById to change the main image. Easy to do but I now want to change my main image from landscape to portrait. This will mean that now when clicking the thumbnail I will not only need to change the main image but also the div tag dimensions. I am new to Javascript and was wondering if someone could give me a quick point in the right direction of how to go about this.

Thank you in advance for any help,

Margate

3
  • Show us some of your HTML. Commented Apr 30, 2013 at 12:55
  • Are you using Jquery by any chance? And can we some code please?? Commented Apr 30, 2013 at 12:55
  • Have you considered using jQuery? Commented Apr 30, 2013 at 13:11

2 Answers 2

0

I would suggest adding/changing a CSS style class on the element and then configuring that class with all the necessary modifications. There's a lot you can do with just CSS.

0

You can either use a semi colon in your onclick event and add more javascript calls, or create a JavaScript function that will do all of your neccesary changes and call that method from your onclick event.

    function changeStuff(){
       document.getElementById("myThing").DoStuff()
       document.getElementById("myOtherThing").DoOtherStuff()
    }

    <div id="myThing">
        <img id="myOtherThing" onclick="cangeStuff();"></img>
    </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.