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

  • Home
  • SEARCH
  • 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 8896271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:59:53+00:00 2026-06-14T23:59:53+00:00

I have this little script. I need to add and remove elements at my

  • 0

I have this little script. I need to add and remove elements at my shop basket. So i have a simple counter, but it’s not work corectly. When i’m parsing actual number and add another one everythin is fine, but – i can’t add another one, and when i’m subctracting it brings me an zero. Can you help me? My code and some fiddle http://jsfiddle.net/5vuJQ/:

$(function(products_counter){
    var n = parseInt($('.lce_number').text());
    var n_place = $('.lce_number');
    $('.lce_add').live('click', function(){
        n_place.empty().append(n + 1);
    });
    $('.lce_remove').live('click', function(){
        n_place.empty().append(n - 1);
    });
});
  • 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-06-14T23:59:54+00:00Added an answer on June 14, 2026 at 11:59 pm

    You have to pick up the number from .lce_number on each click. Note, live() method was deprecated, you should use on() instead.

    var n_place = $('.lce_number');
    $('.line_count_elements').on('click', '.lce_add', function() {
        var n = parseInt(n_place.text(), 10);
        n_place.html(n + 1);
    });
    $('.line_count_elements').on('click', '.lce_remove', function() {
        var n = parseInt(n_place.text(), 10);
        n_place.html(Math.max(0, n - 1));
    });​
    

    DEMO: http://jsfiddle.net/5vuJQ/7/

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

Sidebar

Related Questions

Need a little help with this script. It's working but I'd love a way
I have this little script that shows one wisdom each day. so I have
This is a little tricky so bear with me: I have a PHP script
I have this little NetStream movie (which I'm not allowed to show, sorry) set
I have this little script, which should ping the IPs in the $hosts_to_ping array.
I need to run a simple script after the modules and programs have been
Ok, so I have this PHP script that runs in a nice little infinite
This may be a simple task but at the moment I really have no
ORIGINAL QUESTION: I have the following script: http://jsfiddle.net/mnXdv/12/ It works well, but I need
I have this little rake task: namespace :db do namespace :test do task :reset

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.