Jump to content

Function only runs once, but why?


Tim Grollman

Recommended Posts

Hi, I'm very rusty on js, so bear with me. I am trying to turn an image ("pp") by pressing a button. I have this much, which rotates it once (in a Chrome browser): function TurnTile19() { document.getElementById("pp").style.webkitTransform="rotate(60deg)" ;} But when I press the button a second time there is no response. The relevant code in the button just says: onclick="TurnTile19()" How can I make it turn whenever I press the button? Thanks for reading. Tim

Link to comment
Share on other sites

Many thanks justsomeguy, Once I figured out that I needed those quotes and pluses to call up the variable, it worked a treat! I was looking at your Benjamin Franklin paraphrase. I don't think you can teach yourself this stuff, you need to use other people and other resources. But you can still take pride in saying "I built my own website, I know (at least for the moment) what every line of code does, because I've cobbled it together from the ground up". Thanks again, I'm sure I'll be back for more.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...