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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:54:19+00:00 2026-05-22T23:54:19+00:00

I have four divs that are draggable. And a div where I drop the

  • 0

I have four divs that are draggable. And a div where I drop the daggable divs. My code is basically just an API I’ve downloaded and modify a little form jQuery’s sites.

My problem is that all the divs have the same function when they are dropped. How can I make individual functions to individual divs?

It looks like this:

$(function() {
$("#draggable").draggable({ revert: "invalid" });
$("#draggable2").draggable({ revert: "invalid" });
$("#draggable3").draggable({ revert: "invalid" });
$("#draggable4").draggable({ revert: "invalid" });

$("#droppable").droppable({
    activeClass: "ui-state-hover",
    hoverClass: "ui-state-active",
    drop: function(event, ui) {
        if (document.getElementById('draggable')){
            window.location.replace("http://www.example.com");      
            }
        if (document.getElementById('draggable2')){
            window.location.replace("http://www.example2.com");     
            }
        if (document.getElementById('draggable3')){
            window.location.replace("http://www.example3.com");     
            }
        if (document.getElementById('draggable4')){
            window.location.replace("http://www.example4.com");     
            }
        }
    });
});

No luck in this code. Any ideas?

Thanks in advance!

Regards, VG

  • 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-22T23:54:20+00:00Added an answer on May 22, 2026 at 11:54 pm

    In your ‘if’ statements you need to do something like:

    if(ui.draggable.attr('id') === 'draggable')
    {
        // do stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four divs contained in another div, and I want the four inner
I have four divs with custom Attributes like: <div marker=A>A1</div> <div marker=A>A2</div> <div marker=B>A3</div>
I have some databases that have four files each; one for PRIMARY, IDX, IMAGE,
I have a database that has four columns like this level_1, level_2, level_3, level_4
I have a script that loops through a series of four (or less) characters
Say I have the following DIVs: <div id=top>Page header</div> <div id=main>Main content</div> <div id=sidebar>Sidebar
I need to figure out what div is visible out of four possible divs
If i have the following markup; <div id=container> <div id=box> <div id='sameHeight'>One<br>two<br>three</div> <div id='sameHeight'>four</div>
I have four divs on a popup and each click makes a ajax call
I have four tabs that hold four listviews, I want to set a background

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.