USer22999299
USer22999299

Reputation: 5694

Simple JQuery script animate not working

So i created a simple html page :

index.html file:

<html>
<head>

</head>
<body>

    <div class="menu">      
        hello
    </div>  
     <div class="test">        
       Menu
     </div> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="app.js"></script>

</body>
</html>

here is the app.js file:

var main = function() {
    $('.test').click(function(){
        $('body').animate({
            left: '500px'
            },200);
    })
}
$(document).ready(main)

I'm trying to understand what i did wrong , it seems like it should work..

was also tried to download jquery-2.1.1.min.js and to work with it , but still while clicking on the menu , the text is not moving ..

Upvotes: 1

Views: 190

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115262

You need to set position css property to body in order to work left.

body{
  position:relative;
}

REF : http://api.jquery.com/animate/

Upvotes: 2

Related Questions