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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:41:54+00:00 2026-06-06T09:41:54+00:00

I tweaked this script that I used from JqueryUi and I have a problem.

  • 0

I tweaked this script that I used from JqueryUi and I have a problem. Both div´s start at the same time. I want each ball to start animate only after is dragged over the special zone.

Question: How can I make them animate one at the time and open the page I am interested after they are doing their animation? Each ball with her properties.

The JavaScript code i am using:

$(document).ready(function(){
    $(function() {
        $("#ball").draggable({ containment: "#cadru_principal", scroll: false, revert: "invalid" });
        $("#ball2").draggable({ containment: "#cadru_principal", scroll: false, revert: "invalid" });
        $( "#dropable" ).droppable({
            drop: function( event, ui ) {
                $("#ball").animate({left: '490px', top: '300px'}, 900);
                setTimeout(function() {window.location.href = "contact.html"}, 900);
                $("#ball2").animate({left: '490px', top: '300px'}, 900);
                setTimeout(function() {window.location.href = "pictori.html"}, 900);
            $( this )
                .find( "p" )
                    .html( "Ai nimerit" );
        }
    }); 
});

});

The HTML:

<div id="ball" class="ui-widget-content"></div>
<div id="ball2" class="ui-widget-content"></div>
<div id="dropable" class="ui-widget-header">
<p>Drop me here</p>

The CSS:

#ball {
position: absolute;
left: 183px;
top: 467px;
width: 42px;
height: 40px;
display: block;
background: url(../Images/ball.png) no-repeat;
background-position: top left;
z-index: 1002;
}
#ball2 {
    position: absolute;
    left: 225px;
    top: 460px;
    width: 42px;
    height: 40px;
    display: block;
    background: url(../../Web4/Images/ball2.png) no-repeat;
    background-position: top left;
    z-index: 1001;
}
  • 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-06T09:41:55+00:00Added an answer on June 6, 2026 at 9:41 am

    To get the element that was dragged you can get use the ui.draggable inside the droppable-drop parameters.

    JsFiddle demo: http://jsfiddle.net/JCNAE/

    The code:

    $(document).ready(function(){
        $(function() {
            $("#ball").draggable({ containment: "#cadru_principal", scroll: false, revert: "invalid" });
            $("#ball2").draggable({ containment: "#cadru_principal", scroll: false, revert: "invalid" });
            $( "#dropable" ).droppable({
                drop: function( event, ui ) {
         //           alert(ui);
                    $(ui.draggable).animate({left: '490px', top: '300px'}, 900,
                                            function(){ //finish animation callback
                                                var url = $(this).attr("data-url");
                                                $("#url").text(url); //navigate here, used a div for testing purposes
                                                      }
                     );              
                $( this ).find( "p" ).html( "Ai nimerit" );
            }
        });
    });
    });
    

    Also as a side note, instead of using a separate timeout to navigate to a url, you can use a callback for when the animate finishes, that is also implemented in the demo above. To be able to assign a url to each div, I assigned a data-url attribute, that can be obtained in the callback.

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

Sidebar

Related Questions

I have a client who wants his script to be tweaked for some modifications.
I've got this strange problem using py-amqp and the Flopsy module. I have written
I found and tweaked this script to find the most recently modified file in
What I want is a memoization decorator that: can memoize instance methods with both
I have a file that looks like this: ... %ldirs (list of line-separated directories)
I got this code from w3schools, and tweaked it based on this one: Rename
so I have this project in java that uses a jni .dll i wrote
I have tweaked the standard jelly template to display the current test results in
I'm getting the good ole' This page contains both secure and nonsecure items. dialog
I'm trying to launch embedded Youtube videos from a UIWebView, but get this error

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.