I'm adding an element on a page but i can't drag it. Can anyone help me out with this.This is my code:
<input type="button" value="clickme" id="clickme">
$(".mainDiv").append("<div id='dragme'>Drag me</div>");
Firstly, $.draggable is a method from jQuery UI package, so if you want to use it, you will have to include it.
Secondly, when you call
$("#dragme").draggable(), the element is not added to the DOM yet and therefore
$("#dragme") will return nothing. You will have to call this function after you add the #dragme element in the page.
Here is a working update of your code: