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 9115127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:21:24+00:00 2026-06-17T04:21:24+00:00

Thanks for looking at this question in advance. I’m using jQuery drag and drop

  • 0

Thanks for looking at this question in advance.

I’m using jQuery drag and drop for a project I’m doing at university and I’m looking to count each drop and change the class that is added on each drop.

Here is the jQuery:

$('#droppableChoking').droppable({
    drop: function (event, ui) {
        //reuse jQuery object
        var $this = $(this);

        //get object type
        var droppedObject = ui.draggable.data('object');

        //css reset
        $this.removeClass();
        $this.addClass("grape" + droppedObject);
        }

        //play drop sound
        audioClap.play();
    }
});

I’ve tried doing a loop and add the value of the count to the class to change it each time but I’m doing something wrong!

  • 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-17T04:21:25+00:00Added an answer on June 17, 2026 at 4:21 am

    http://api.jquery.com/removeClass/ removeClass requires One or more space-separated classes to be removed from the class attribute of each matched element.

    So with that in mind, your call to removeClass isn’t likely removing anything. If you want to clear out the class, then do $this.attr('class', '')

    As for a counter, here is my updated JS:

        var counter = 0;
    
        $('#droppableChoking').droppable({
                drop: function (event, ui) {
                    ++counter;
    
                    //reuse jQuery object
                    var $this = $(this);
                    //get object type
                    var droppedObject = ui.draggable.data('object');
                    //css reset
                    $this.attr('class', '');
                    $this.addClass("grape" + droppedObject);
    
                    // what to do with counter?  not sure.  Whatever you want.  I'm setting text.  Not sure how you want to use it for the class.
                    $this.text(counter);
                    }
                    //play drop sound
                    audioClap.play();
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an questions for you, thanks in advance for looking this question. I
Firstly thanks in advance for your time looking at this question. I'm trying to
Thanks for looking at this question. I wanted to know how can I use
and thanks for looking at this question. I am porting a Linux (2.6.37) driver
Hi and thanks for looking at this newbi question. I have looked for anykind
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an
Hi there and thanks for taking the time for this question. I'm using a
I was looking around for jQuery grid recommendations and came across this question/answers: https://stackoverflow.com/questions/159025/jquery-grid-recommendations
Thanks for looking on this problem. I have a page that is totally valid
Thanks for looking, all helpful answers are voted up. This is my markup. I'm

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.