Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 596579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:11:12+00:00 2026-05-13T16:11:12+00:00

I’m building a site (with jQuery 1.4) which has a floating (fixed position) basket.

  • 0

I’m building a site (with jQuery 1.4) which has a floating (fixed position) basket.

Current working functionality (Demo here):

  • When the user clicks the basket itself it toggle slides open/closed and toggles a “locked on” class
  • When the user clicks an ‘add item’ link in the page it slides open, adds an “on” class and fades in a notice saying that “item name” has been added

What I’m struggling with

  • If the user clicked an ‘add item’ link: after 3 seconds the notice should fade out, the basket slide closed, and the “on” class be removed. BUT this needs to take into account if the user frantically clicks 10 things quickly; updating the added track name notice text without queueing up a bunch of fades/slides – rather just staying open nicely and then sliding closed 3 seconds from the last item being added. AND if the basket’s class is “locked” (ie; opened by user already) then only the notice should fade out, the basket should remain open.

javascript so far

//Toggle basket directly
$("#basket-button").click(function(){
    $("#basket-contents").slideToggle();
    $("#floating-basket").toggleClass("locked on");
    return false
});
//Toggle basket with a 'buy now' button
$(".buy-button").click(function(){
    //open basket 
    $("#basket-contents").slideDown();
    $("#floating-basket").addClass("on");
    //set track name
    $("#basket-trackname").text($(this).attr('name'));
    //Display basket message
    $("#basket-message").fadeIn();
    return false
});

html

<a class="buy-button" name="Item Name one" href="#">Buy</a>
<a class="buy-button" name="Item Name two" href="#">Buy</a>

<div id="floating-basket">
    <div id="basket-message">
        <strong id="basket-trackname"></strong> added to basket!
    </div>
    <a href="/basket" id="basket-button">My Basket <span id="basket-number">0</span></a>
    <div id="basket-contents">
        lorem
        <a href="#">Checkout</a>
    </div>
</div>

http://www.webresourcesdepot.com/ajaxed-sliding-shopping-cart-with-jquery is the closest thing I found – but even this is problematic (if you add an item and quickly close the basket for example).

Would really appreciate some input 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:11:12+00:00Added an answer on May 13, 2026 at 4:11 pm

    learn about setTimeout and clearTimeout

    var t = setTimeout(function(){ whattodo(); }, 3000);
    

    will do anonym function, which basically consists only of whattodo() function (which could hide basket, etc.)

    then in each click, .stop() animation and call:

    clearTimeout(t); // clears previous timeout
    t = setTimeout(function(){ whattodo(); }, 3000); //set new timeout
    

    so, setTimeout/clearTimeout are to time hiding in 3 seconds, while .stop() stops ongoing animation – learn more @ http://api.jquery.com/stop/ – basic usage:

    $(myelementwithanimation).stop()
    

    and more about timeouts: http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.