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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:23:57+00:00 2026-06-12T21:23:57+00:00

I am dragging text from a paragraph with text / html to a contenteditable

  • 0

I am dragging text from a paragraph with text / html to a contenteditable div.
I would like to add a wrapping div to the dropped selected text.
I have tried manipulating all the drag and drop listeners with no success.
I thought of manipulating via dataTransfer – but it seems to fail.

e.dataTransfer.setData('Text', '<div>' + e.dataTransfer.getData('Text') +'</div>');

Any ideas?

  • 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-12T21:23:58+00:00Added an answer on June 12, 2026 at 9:23 pm

    I did the drag/drop code for chrome recently (v24). It appears you need to specify the dragover handler for the drop target and call event.preventDefault(); action on it, otherwise the drop wont work.

    If your problem is only the wrapping of the dragged content, you have a nice example here html5rock presentation

    As the previous answer states, you can get the dropped content on the drop handler. Although in chrome I use

     var text = e.dataTransfer.getData('text/plain');
     var html = e.dataTransfer.getData('text/html');
    

    You can get all available mime types by examining the e.dataTransfer.types

    It seems that you can set the dragged content on dragstart, but not read it, so this is only available on drop event listener.

     event.dataTransfer.getData('text/plain')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to drag a row from a JQGrid to a text input
I've got a listbox from which I'm dragging into the ListView. Now I have
I am trying to scroll by highlighting text and dragging down. Now, as you
Browsers allow text-areas to be re-sized by dragging their corner by default. I was
I am trying to configure my text file viewer to open files by dragging
When dragging something over a contenteditable area in Chrome, to be able to catch
After dragging two tables in from one database, I switch to another and drag
I tried implementing dragging on android in 2 ways: Canvas with on draw. Relative
I'm dragging from a TileList to a custom component. I want to know what
how would you prevent dragging for some items of your List or DataGrid? Let's

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.