JavaScript Append div based on dragend mouse coordinates

I want to append div based on dragend event coordinates. This is what I have tried:

 $(document).ready(function () {
            var mouseX;
            var mouseY;
            $(document).mousemove(function (e) {
                mouseX = e.pageX;
                mouseY = e.pageY;
            });
            var i =1;
            $(".ic_table").on("dragend", function (e, ui)
            {
                console.log(mouseX + " " + mouseY);
                var editName = "Edit Name";
                $('#datamodelArea').append('<div id="divDT' + i++ + '" class="dataModelTable ui-draggable ui-draggable-handle style="left:' + mouseX + 'px' + '; top:' + mouseY + 'px' + ';"><div class="dataTableName">' + editName + '</div><div class="widget"><div class="widget-head"> <a target='_blank' href="#" id="toggle1" class="fa fa-chevron-up fa-1x attributes"><i></i></a> Attributes <div class="widget-body attributesBody" id="widget-body1"></div></div></div><div class="widget-body attributesBody" id="widget-body1"><ul></ul></div></div>');
                $('.form-control').val('');
            });
        });

Html:

<body>
        <div id="datamodelArea"></div>
        <button class="ic_table" draggable="true">Submit</button>
</body>

Its appending only to top:0px and left:0px even though the mouse coordinates are different on dragend

Answer:1

I have succesfully implemented the DataTables (version 1.10+) pagination plugin with textbox but I would like to allow the user to first enter a page number and then to press the enter key. By default,...

I have succesfully implemented the DataTables (version 1.10+) pagination plugin with textbox but I would like to allow the user to first enter a page number and then to press the enter key. By default,...

Lets say I have two pages on my website, Home and Settings. A user visits Home, then presses Settings. They decide to go back to Home via the back button, or pressing escape on the key board, or ...

Lets say I have two pages on my website, Home and Settings. A user visits Home, then presses Settings. They decide to go back to Home via the back button, or pressing escape on the key board, or ...

  1. react lifecycle method before render
  2. react lifecycle method after render
  3. react lifecycle method order
  4. react lifecycle method when props change
  5. react lifecycle methods list
  6. react lifecycle methods explained
  7. react lifecycle methods diagram
  8. react lifecycle methods hooks
  9. react lifecycle methods 2020
  10. react lifecycle methods vs hooks
  11. react lifecycle methods 2019
  12. react lifecycle methods chart
  13. react lifecycle methods tutorial
  14. react lifecycle methods medium
  15. react lifecycle methods async
  16. react lifecycle methods 16.8
  17. react lifecycle methods update state
  18. react lifecycle methods interview questions
  19. react lifecycle methods in functional components
  20. react lifecycle methods deprecated

So in my PHP file I create a JSON Object which I need to get to my Javascript file for processing. I can't seem to transfer anything however, not even with a simple string like this:- index.php <?...

So in my PHP file I create a JSON Object which I need to get to my Javascript file for processing. I can't seem to transfer anything however, not even with a simple string like this:- index.php <?...

  1. cannot return value from iterator
  2. cannot cast value from string to double
  3. cannot return a value from a method which is void
  4. cannot read property value from undefined
  5. cannot read property value from null

For some reason when I echo inside the value="" of a hidden input tag. It for some reason has a max character size. Its much smaller then I need it to be as I need it to put content from my DB into ...

For some reason when I echo inside the value="" of a hidden input tag. It for some reason has a max character size. Its much smaller then I need it to be as I need it to put content from my DB into ...

  1. hidden input value jquery
  2. hidden input value javascript
  3. hidden input value html
  4. hidden input value change event jquery
  5. hidden input value change jquery
  6. hidden input value
  7. hidden input value change event
  8. hidden input value not setting
  9. hidden input value array
  10. hidden input value change
  11. hidden input value empty
  12. hidden input value php
  13. hidden input value angular
  14. hidden input value true
  15. hidden input value angularjs
  16. hidden input value get
  17. input hidden value boolean
  18. input hidden value js
  19. input hidden value undefined
  20. input hidden value php post