Tim Grollman Posted March 22, 2013 Share Posted March 22, 2013 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 More sharing options...
justsomeguy Posted March 22, 2013 Share Posted March 22, 2013 You need to figure out what the current rotation is and add to it. The first click you would rotate it 60, then 120, 180, 240, etc. Link to comment Share on other sites More sharing options...
Tim Grollman Posted March 22, 2013 Author Share Posted March 22, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now