Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    18
    Member #
    28659
    Liked
    1 times
    Hi All,

    I am just starting to entertain the idea of using some simply jquery functions in my web work. I was checking out a very simple tutorial on animation queues (see http://api.jquery.com/queue/) and I understand (i think) how the jquery, css and html are interacting. Because I want to run any scripts I use as external files, I attempted to separate this into separate .htm, .css and .js files but could not get the animation to work. Any help would be appreciated. I have attached the three sets of code...see the link for the original inline solution. Save for a few deletions, I don't think I changed anything important...did I??

    Code:
    HTML:
    
    
    <!DOCTYPE html>
    
    <html>
    
    <head>
    
        <script type="text/javascript" src="jquery.min.js"></script>
        <script type="text/javascript" src="queue.js"></script>
        <link href="style.css" rel="stylesheet" type="text/css" />
    
    </head>
    
    <body>
    
    <p>The queue length is: <span></span></p>
    
    <div></div>
    
    </body>
     
    </html>
    
    
    CSS:
    
    
    div {
        margin:3px;
        width:40px;
        height:40px;
            position:absolute;
        left:0px; top:60px;
            background:green;
        display:none;
    }
    
    p {
        color:red;
    }
    
    
    JS:
    
    
    var div = $("div");
    
    function runIt() {
      div.show("slow");
      div.animate({left:'+=200'},2000);
      div.slideToggle(1000);
      div.slideToggle("fast");
      div.animate({left:'-=200'},1500);
      div.hide("slow");
      div.show(1200);
      div.slideUp("normal", runIt);
    }
    
    function showIt() {
      var n = div.queue("fx");
      $("span").text( n.length );
      setTimeout(showIt, 100);
    }
    
    runIt();
    showIt();

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Upload your code somewhere and show us your page. On the surface, it seems fine.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    18
    Member #
    28659
    Liked
    1 times
    i don't have it up anywhere, I've just been messing around in my browser. I have copied and pasted and got exactly what they have in the tutorial demo, but then when i break it up the red text appears with no animation. rats.

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    That might be why. I've seen cases (in IE in particular) where jQuery code doesn't run locally and generates no error, but does as soon as IE thinks there's a site involved. Now, because I have IIS configured on my computers, I simply create a new virtual directory and the problem is solved. But that takes more work and you're better off uploading it somewhere to see if it works.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Junior Member
    Join Date
    Jul 2011
    Posts
    18
    Member #
    28659
    Liked
    1 times
    Sorry about not getting back sooner, been run off my feet at work. Thanks for the reply GAME, I ended up solving the problem. Being a complete noob, I hadn't inserted a proper function in my HTML page.

    So under:

    <script type="text/javascript" src="queue.js"></script>
    I added:
    <script type="text/javascript">
    $(document).ready(function() {
    runIt();
    showIt();
    });
    </script>

    ...and all worked perfectly!

    Thanks again!


Remove Ads

Posting Permissions

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

Search tags for this page

sample jquery external file

Click on a term to search for related topics.
All times are GMT -6. The time now is 10:29 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com