Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery animation ul list

<style>
.myNewsSlider
{
width:200px;
height:44px;
overflow:hidden;
position:relative;
 }

 .myNewsList
 {
margin:0px; 
padding:0px;
position: absolute;
 }
</style>

<div class="myNewsSlider">
  <ul class="myNewsList">
    <li>first element</li>
    <li>second element</li>
    <li>third element</li>
  </ul>
</div>

I want the list to move from bottom to top and show each element for 5 seconds.

The first element will show for 5 seconds, then disappear, and the second element will show for 5 seconds, etc.

How do I use Jquery to complete this task?

like image 843
user1645112 Avatar asked Mar 07 '26 21:03

user1645112


1 Answers

Working demo much simpler : http://jsfiddle.net/aLprr/

APIs used:

  • .promise - http://api.jquery.com/promise/
  • .delay - http://api.jquery.com/delay/
  • .fadeOut - http://api.jquery.com/?ns0=1&s=.fadeOut&go=

Hope it fits the cause :)

P.S. - play around with the 5000 calculation.

Code

$("document").ready(function() {
    $('ul li').each(function(index) {
        $(this).delay(4000 * index).fadeOut(500).promise(function() {
            $(this).remove();
        });
    });


});​
like image 164
Tats_innit Avatar answered Mar 09 '26 22:03

Tats_innit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!