admin管理员组

文章数量:1434889

I'm using the following javascript to animate a div, but the div isn't animating... does anyone know what can be?

JavaScript:

 <script language="JavaScript">   
    $(document).ready(function(){
    $('#LayoutDiv1').animate({top: "500px"}, 1500); }); 
    </script>

HTML:

<div id="LayoutDiv1">
    <img src="images/logo.png">
</div>

CSS:

#LayoutDiv1 {
    clear: both;
    float: left;
    width: 100%;
    display: block;
}

I'm using the following javascript to animate a div, but the div isn't animating... does anyone know what can be?

JavaScript:

 <script language="JavaScript">   
    $(document).ready(function(){
    $('#LayoutDiv1').animate({top: "500px"}, 1500); }); 
    </script>

HTML:

<div id="LayoutDiv1">
    <img src="images/logo.png">
</div>

CSS:

#LayoutDiv1 {
    clear: both;
    float: left;
    width: 100%;
    display: block;
}
Share Improve this question edited Aug 6, 2012 at 17:02 Wilson Junior asked Aug 6, 2012 at 16:56 Wilson JuniorWilson Junior 572 silver badges6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Working Demo : http://jsfiddle/LRuZp/3/

The position property should be specified, when defining top, left, bottom and right properties.

you need to set your div position to relative

#LayoutDiv1 {
    clear: both;
    float: left;
    width: 100%;
    display: block;

    position: relative

}

本文标签: javascriptJquery animate function not workingStack Overflow