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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:27:37+00:00 2026-05-11T17:27:37+00:00

I am simply looking for a way of using drag and drop without jquery

  • 0

I am simply looking for a way of using drag and drop without jquery or any other library. If a dragged object is dropped on another element the later element should start an event (in FF – better would be browser independent).

I know that drag and drop for JavaScript was discussed sometimes before but the previous postings didn’t help me.

Although I found some examples it is not clear to me if there is a “drop” or “dragdrop” events exist but these things don’t work:

<p ondrop='alert("It worked");'>Text</p>
<p ondragdrop='alert("It worked");'>Text</p>

How could this be done?

Many thanks in advance.

  • 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-11T17:27:38+00:00Added an answer on May 11, 2026 at 5:27 pm

    I agree with the other answers. A library will save you a lot of time and headache. This is coming from someone who just recently created a drag-and-drop control from scratch.

    If you insist though this is what you’ll need to do:

    1. Bind a onmousedown event to the div you want to drag (div.onmousedown).
    2. Change the div’s position style to absolute (div.style.position = ‘absolute’)
    3. Begin capturing mouse movement (document.onmousemove).
    4. On mouse move update the div’s position (div.style.top|left = ‘[location]px’)
    5. On the div’s onmouseup event (or the document’s) unbind all the handlers and do any other cleanup (null out position changes, etc).

    Some problems a library will probably solve:

    1. While dragging you will select text on the page (looks ugly).
    2. Binding to events is different between browsers.
    3. You have to calculate the size of the element being dragged if you want to show placeholders and to make it not “pop” when you begin dragging the control (since changing to absolute positioning will remove the element from flow).
    4. You will probably want your dragged element to move fluidly so you will have to store some mouse offset when selecting the element or automatically center the element to the mouse.
    5. If you want to drag an item in a list you’ll have to write a ton more custom code for that list to accept the dragged item.
    6. You’ll have to take into consideration dragging when the window is scrolled and possibly dragging inside other elements that are positioned strangely.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a simple way to tokenize std::string input without using non default
I'm looking for a way to play an audio stream on android without using
I'm looking for a way to map a simple insert stored procedure using NHibernate
I'm looking for a way to create a GUI (using Cocoa) to make a
Im looking for a way to change the background image of a div using
I am looking for a way to display other data in a MaskedTextBox than
I am looking for a way to chart data using C# .NET. I have
I'm looking for a simple way to translate long to String and back in
I'm looking for a simple way to have this done. I would to have
I am looking for a simple way (UDF?) to establish the similarity between strings.

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.