Creating a draggable div using jquery
Sorry, really new at this. So I used the jQuery UI to create a draggable div, like so:
- <div id="draggable" class="ui-widget-content">
- <p>Drag me around</p>
- </div>
I've also implemented the jQuery UI button, and I want the button, when clicked, to create a duplicate div, like so:
- $(function() {
- $( "input[type=submit], a, button" )
- .button()
- .click(function( ) {
- $( "<div id='draggable' class='ui-widget-content'><p>Drag me around</p></div>" ).appendTo( "body" );
- });
- });
It creates the div like I want, however it's not draggable. When I inspect the element, the original div has a bunch of other properties like "
ui-widget-content ui-draggable ui-draggable-handle". Does anyone know why that is? And what can I do to get the new div to behave like the original?