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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:01:42+00:00 2026-05-28T07:01:42+00:00

My problem is similar to the below link How to get the dropped item's

  • 0

My problem is similar to the below link

How to get the dropped item's id on drop event jquery

However I am dragging and dropping a list item, each contain images.

When the list item is dropped, I need to get the ‘id’ attribute, which will then be passed to php on ‘submit’, to update the database.

But the below code does not seem to be capturing the ‘id’ attribute or if i try ‘src’, I have amended the following

$("#drop").text(id); to $("#drop").text("image has been dropped");

which does display correctly, “image has been dropped” upon a drop event, so the problem seems to be with getting the ‘id’ attribute within a list item? I tried adding a class called ‘image’ to use instead of the list item, tried many things, but makes no difference!

Hope someone can point me in the right direction!

Thanks

below is my code

JQuery

$(document).ready(function() {

    $("#item-slider li").draggable({
        containment: 'document',
        revert: true,
        helper: "clone",
        cursor: "move"
    });


    $("#drop").droppable({
        accept: "#item-slider li",
        drop: function (event, ui){
            var draggable = ui.draggable;
            var id = draggable.attr("id");
            $("#drop").text(id);
        }
    });

});

Html

<div id="item-slider">
<ul>
    <li class='image'><img src="./images/jeans1.jpeg" id="jeans1.jpeg" /></li>
    <li class='image'><img src="./images/top2.jpg" id="top2.jpg" /></li>
    <li class='image'><img src="./images/top1.jpg" id="top1.jpg" /></li>
    <li class='image'><img src="./images/shoes3.jpg" id="shoes3.jpg" /></li>
    <li class='image'><img src="./images/dress1.jpg" id="dress1.jpg" /></li>
</ul>

<div id="drop">
</div>
</div>
  • 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-28T07:01:43+00:00Added an answer on May 28, 2026 at 7:01 am

    The id attributes you’re looking for do not belong to your <div> elements, but to their <img> children. You can match these elements with find() or children():

    drop: function(event, ui) {
        var id = ui.draggable.find("img").attr("id");
        $("#drop").text(id);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem similar to the one described in the link below. NSHTTPURLResponse
This is a similar problem: Link Which was solved by calling GetAsyncKeyState(). While all
I am getting a java.lang.IllegalArgumentException similar to the link given below.To solve it I
I've got a problem similar to,but subtly different from, that described here (Loading assemblies
I have a problem similar to the egg and the chicken. I have two
My problem is similar to Django Passing Custom Form Parameters to Formset Ive have
I have similar problem to one discussed here , but with stronger practical usage.
This problem is similar to when creating alternate colour table-rows, only we are dealing
I suppose similar problem would have been discussed here, but I couldn't find it.
I have a similar problem to this post . I need to display up

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.