JavaScript Drag and drop a div added into another div

Scenario

I am having a functionality in my project in which we have to add a note in a section and then it can be moved to the other sections. It is a sort of task tracking. I am able to add a note dynamically created into one section and have made that note dragable. The note, sections are divs.

Problem

I am not able to drag the note to the other section or div. the note is draggable in its own section (div). Please help me with the solution so that it can be moved to other section.

Here is my HTML code:

<div id="addTaskDiv" style="height: 150px">
        <a id="addTask" onclick="AddNote();">ADD Task</a> <a id="a1" onclick="AddText();">Submit</a>
    </div>
    <div id="MySplitter">
        <div id="leftDiv" style="height: 150px; border-style: groove; width: 100%;">
            left here
        </div>
        <div id="splitterUpperDiv">
            <div id="midDiv" style="height: 150px; border-style: groove; width: 100%;">
                middle here
            </div>
            <div id="rightDiv" style="height: 150px; width: 100%; border-style: groove;">
                right here
            </div>
        </div>
    </div>

Here is my .js

$().ready(function () {
    $("#MySplitter").splitter();
    $("#splitterUpperDiv").splitter();
    $("#rightDiv").droppable();
    $("#midDiv").droppable();
    $("#leftDiv").droppable();
});

function AddNote(args, seder) {
    var i = (typeof this.rel != 'undefined') && (this.rel - 0) == this.rel ? this.rel : 0;
    var br = document.createElement("br");
    $("#addTaskDiv")[0].appendChild(br);
    addArea();
    return false;
}

function addArea() {
    var i = (typeof this.rel != 'undefined') && (this.rel - 0) == this.rel ? this.rel : 0;
    var button = $(this);
    var commentField = $('<textarea/>'); // create a textarea element
    commentField[0].id = 'added' + i;

    commentField
        .css({
            position: 'absolute',
            width: 200,          // textbox 200px by 100px
            height: 100
        })
    // set the textarea's value to be the saved content, or a default if there is no saved content
        .val(button.data('textContent') || 'This is my comment field\'s text')
    // set up a keypress handler on the textarea
        .keypress(function (e) {
            if (e.which === 13) { // if it's the enter button
                e.preventDefault(); // ignore the line break
                button.data('textContent', this.value); // save the content to the button
                $(this).remove(); // remove the textarea
            }
        })
        .appendTo($("#addTaskDiv")[0]); // add the textarea to the document
}

function AddText() {
    var i = (typeof this.rel != 'undefined') && (this.rel - 0) == this.rel ? this.rel : 0;
    var a = $("#added0")[0].value;
    var x = document.createElement("div");
    x.width = '200px';
    x.height = 'auto';
    x.id = 'lable' + i;
    this.rel = i + 1;
    x.innerText = a;
    var br = document.createElement("br");
    $("#leftDiv")[0].appendChild(br);
    $("#leftDiv")[0].appendChild(x);
    $("#lable" + i + "").draggable();
}
Answer:1

You can try this :-

$("#rightDiv").droppable({
 accept: '.draggableObject',
});
Answer:2

I Have a jquery export table to excel code. But the problem is that it changes the value is export file of xls. my table td has a value 810101E001 when I export it it changes the value like 8.10E+06. ...

I Have a jquery export table to excel code. But the problem is that it changes the value is export file of xls. my table td has a value 810101E001 when I export it it changes the value like 8.10E+06. ...

  1. jquery export table to csv
  2. jquery export table to excel
  3. jquery export table to pdf
  4. jquery export table to xlsx
  5. jquery export table to excel plugin
  6. jquery export table to excel xlsx
  7. jquery export table to pdf plugin
  8. jquery export table
  9. jquery export table to excel utf-8
  10. jquery export table data to excel
  11. jquery export table data with images to excel
  12. jquery export table to csv file
  13. jquery export table to xls
  14. jquery export table to excel and pdf
  15. jquery export table to word
  16. jquery export table to xml
  17. jquery export table to json
  18. jquery export table to excel jsfiddle
  19. jquery export table html
  20. jquery table export to excel example

this is a pure academic question. is it better practice to add new elements to the dom this way with create new element <div id="div1"> <p id="p1">This is a paragraph.</p> <p id="...

this is a pure academic question. is it better practice to add new elements to the dom this way with create new element <div id="div1"> <p id="p1">This is a paragraph.</p> <p id="...

  1. create element append javascript
  2. create element append child
  3. create element append to body
  4. create element append
  5. create element and append jquery
  6. javascript create element append to body
  7. jquery create element append to body
  8. js create element append
  9. document createelement append
  10. js create element appendchild
  11. create element and append to dom
  12. javascript create element and append to div
  13. jquery create element and append child
  14. jquery create element and append to div
  15. js create element and append to body
  16. angular create element and append
  17. jquery create element then append
  18. js create element and append to div
  19. create new element and append jquery
  20. create html element and append jquery

A basic function: function myStuff(a,b,c){ var _c = _c || c || {}; console.log(_c); } The idea is to use a cached value if used before, or a new value if new/different. The question is: if ...

A basic function: function myStuff(a,b,c){ var _c = _c || c || {}; console.log(_c); } The idea is to use a cached value if used before, or a new value if new/different. The question is: if ...

  1. javascript cache function result
  2. javascript cache function
  3. clear cache function javascript
  4. javascript function clear browser cache

Can phantomjs perform actions like getText() or enterText() inside iFrame? I am using protractor to do my testing. Phantomjs can perform actions in the default frame but inside iframe the locators get ...

Can phantomjs perform actions like getText() or enterText() inside iFrame? I am using protractor to do my testing. Phantomjs can perform actions in the default frame but inside iframe the locators get ...

  1. accessing elements inside iframe