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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:24:49+00:00 2026-05-23T21:24:49+00:00

I am working with jquery draggables and droppables, and can’t figure out why it

  • 0

I am working with jquery draggables and droppables, and can’t figure out why it appears that a div I have,

 <li class="ui-widget-header"><img style="position: relative; left: 10px; top: 50px;" src=""></img></li>

does not seem capable of displaying both an image and text at the same time. The div above is my droppable; I am trying to drag both images and text to it. When I drag the images first, they work fine, but once I try to drag text, the images no longer display (although the droppable does acknowledge that the image was dragged there).

Here is my droppable code, although I’m not sure whether the problem stems from something in my html or from this (note: the ‘li’ above is the droppable):

drop: function(event,ui) {
                if (ui.draggable.find("img").length) {
                   $(this)
                        .addClass("ui-state-highlight");
                   $("img", this).attr("src",  ui.draggable.find("img").attr("src"));
                } else {
                    $(this)
                        .addClass("ui-state-highlight")
                            .text(ui.draggable.text());
                }
}

Any suggestions would be appreciated. Thanks!

  • 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-23T21:24:50+00:00Added an answer on May 23, 2026 at 9:24 pm

    This is because of your Javascript code. On text drop, you’re setting the .text value of your <li> tag to the dragged text, which overwrites the <img> tag you had in there. Do you just want this to append text to whatever is in the <li> then?

    This change below to your else block should append a new paragraph with the included text below your image. Obviously, feel free to change the paragraph to whatever you want.

            } else {
                $(this)
                    .addClass("ui-state-highlight")
                        .append('<p>' + ui.draggable.text() + '</p>');
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery plugin that i'm working with for a website and I
I have a draggable container that was working with jquery 1.3.2. I recently upgraded
I have a draggable object, with that can be accepted in several droppables.. I
I have working in jquery sortable, all are working fine. but empty div will
I'm working with jQuery for the first time and need some help. I have
I'm working with jQuery UI's droppables and am wondering what the best way to
I'm working with jquery. And i have text input in a form, i would
UPDATE I have reverted back to Jquery 1.3.2 and everything is working, not sure
im working with the jquery ui draggable plugin and i have an html 5
I have a jquery scrollable that is not constrained to be within it's parent.

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.