最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Jquery animate function not working - Stack Overflow

matteradmin9PV0评论

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

}
Post a comment

comment list (0)

  1. No comments so far