2

Hi guys at the moment i am trying to figure out how to rotate a div and make it stop at a loctation. I have had some help on this however iam not sure what iam doing wrong. Any help with the code would be great.

Thanks guys for the help

2 Answers 2

3

try change your javascript code to be like this:

$(window).load(function(){
var $elie = $("#super");
rotate(1);

function rotate(degree) {
$elie.css({
'-webkit-transform': 'rotate(' + degree + 'deg)',
'-moz-transform': 'rotate(' + degree + 'deg)',
'-o-transform': 'rotate(' + degree + 'deg)',
'-ms-transform': 'rotate(' + degree + 'deg)',
'transform': 'rotate(' + degree + 'deg)'
});
console.log(degree);
if (degree < 100) {
timer = setTimeout(function() {
    rotate(++degree)
}, 1);
}} 
});

Here the demo: http://jsfiddle.net/ongisnade/mq8Ar/

Sign up to request clarification or add additional context in comments.

Comments

1

Look at here http://jsbin.com/uwunaw/4/edit

I'm adding var elie = null; as global var and put elie = $("#super"); in onReady of jQuery.

Like this

$(function () {
    elie = $("#super");
    rotate(1);
});

It's working now.

Comments

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.