www.webdeveloper.com
Results 1 to 4 of 4

Thread: Help with small coding change?

  1. #1
    Join Date
    Aug 2011
    Posts
    18

    Help with small coding change?

    I am using the following code to trigger an animation to begin again (start over) by clicking on a button. Instead, I would like to trigger the same action when the page loads so no button is involved.

    Is there a way to convert this code to do that? Many thanks for any help!

    Code:
    <script type="text/javascript">
    	$(document).ready(function(){
        $('button').on('click', function(){
            $('img').attr('src', 'animations/washington.gif');
    
        });
    
    });
    	</script>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,377
    Try putting the call to the animation function in a <script> tag just before the end </body> tag.

    Alternatively, you could call the function within an onload="xxx" in the initial <body> tag.

    Or, ..... would need to see your current code for other possibilities.

  3. #3
    Join Date
    Aug 2011
    Posts
    18
    Hi, JMRKER--

    Thank you for your reply. It appears this is not going to be as easy as I hoped.

    Here is the fuller code in case that makes a difference?

    Code:
    <section>      
           
           <div class="animations"><img alt="image here" width="100%" height="100%" src="images/1.gif"> </div>  
     
         <script type="text/javascript">
    	$(document).ready(function(){
    
            $('img').attr('src', 'animations/washington.gif');
    
    });
    
    	</script>	     
     
      </section>
    "section" are pages on a slider. It does work when I use the button, but as I said, I need to have the animation reload/start from beginning on entering the particular page/section. Also, I will be doing this about 7 times total with different animated gifs on separate pages/sections on the slider.

    Again, many thanks for any help!

  4. #4
    Join Date
    Aug 2011
    Posts
    18
    The problem is that the animation is loading immediately and not waiting for the user to arrive at that particular section of the slider. And the fix needs to be applicable to particular sections/pages in other parts of the slider, as well, but not to all the sections...

    Hmmm...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles