Click here to Skip to main content
15,881,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone
I want to use settimeout() function with .each function.Basically iwant to show each image for 5 seconds and then next but i am only able to see last image.The .each executes and do not stop for 3 seconds.How can i do this?This is how i am doing.
JavaScript
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $('#Images').find('li').each(function () {
                var img = this;
                setTimeout(function () {
                    Start(img);
                }, 3000);

            });


        });
        function Start(img) {
            $('#slideshow').html(img);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="slideshow">
    
    </div>
    <div style="display:none;">
    <ul id="Images">
    <li><img src="images/ajax-loader.gif" /></li>
    <li><img src="images/Ajax Loader White.gif" /></li>
    <li><img src="images/fancybox_sprite.png" /></li>
    </ul>
    </div>
    </form>
</body>
</html>

Please help.
Thanks.
Posted

1 solution

You are using jQuery so why not use $.delay()

http://api.jquery.com/delay/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900