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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:25:18+00:00 2026-06-04T17:25:18+00:00

I was trying to learn jQuery drag and drop using the fiddle . Though

  • 0

I was trying to learn jQuery drag and drop using the fiddle. Though I am new to jQuery, I am so confused with jQuery and jQuery UI. What else do I need to install?

I have installed jquery-1.6.3.js and jquery-ui.1.8.16.js. But it’s not running.

How can I make it run?

The code is:

<p class="section">Drag and Drop</p>
<script type="text/javascript" src="/js/jquery-1.6.3.js"></script>
<script type="text/javascript" src="/js/jquery-ui.1.8.16.js"></script>
<script type="text/javascript">
    $('#draggable li').draggable({
        revertDuration: 100,
        helper: function() {
            var selected = $('#draggable img.selected');

            if (selected.length === 0) {
                selected = $('img', $(this)).addClass('selected');
            }
            var container = $('<div class="image-group"/>');
            container.append(selected.clone());
            return container;
        },
        cursorAt: {
            left: 25,
            top: 25
        }
    });

    $('#trash').droppable({
        drop: function(event, ui) {
            var newItems = $(ui.helper).find('img').clone(false).removeClass('selected');
            $(this).append(newItems);
            $('#draggable img.selected').parent().remove();
        }
    });

    $('#draggable li').click(function(event) {
        if (event.ctrlKey) {
            $('img', $(this)).toggleClass('selected');
        }
    });
</script>

<style>
    body {
        font-family:"Trebuchet MS";
    }
    #draggable {
        margin:0;
        padding:10px;
        width:300px;
        list-style-type:none;
        background-color:#000;
    }
    li {
        display:inline;
    }
    img {
        border:5px solid white;
    }
    .image-group img {
        margin-right:5px;
    }
    #trash {
        margin-top:10px;
        width:200px;
        height:200px;
        border:1px dotted #000;
    }
    .selected {
        border-color:#aed0ea
    }
    #trash h4 {
        margin:0;
        padding:0 5px;
    }
    .ui-icon {
        display:inline-block;
    }
</style>

<ul id="draggable">
    <li><img src="http://lorempixel.com/output/nature-q-c-50-50-1.jpg" alt="" /></li>
    <li><img src="http://lorempixel.com/output/nature-q-c-50-50-2.jpg" alt="" /></li>
    <li><img src="http://lorempixel.com/output/nature-q-c-50-50-3.jpg" alt="" /></li>
    <li><img src="http://lorempixel.com/output/nature-q-c-50-50-4.jpg" alt="" /></li>
    <li><img src="http://lorempixel.com/output/nature-q-c-50-50-5.jpg" alt="" /></li>
    <li><img src="http://lorempixel.com/output/nature-q-c-50-50-6.jpg" alt="" /></li>
</ul>
<p>Single left click+drag or Ctrl+left click to select multiple</p>
<div id="trash">
    <h4 class="ui-widget-header">Drop Here<span class="ui-icon ui-icon-trash"></span></h4>
</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-06-04T17:25:19+00:00Added an answer on June 4, 2026 at 5:25 pm

    You whole script need to be wrapped by

       $(document).ready(function() {
         // your script
    
       });
    

    In short,

       $(function() {
          // your script
    
       });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn javascript/jquery, using firebug to debug and have built a
I have been experimenting and trying to learn JQuery, using AJAX to consume a
I'm new to jquery but I'm trying to learn. I'm working with a drop
I'm new to jquery but I'm trying to learn. I'm working with a drop
I am trying to learn javascript and jquery, as projects i have mage image
Actually I am trying to learn jQuery Ajax calls to asp.Net webservices. I have
I am new to JQuery. I have a select html element. I am trying
I am trying to learn new stuff about jquery, html, asp .net mvc. I
I have the following controller and view. I am trying to learn jquery in
I am new to jquery & autocomplete, and am trying to learn them. The

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.