I am currently working on making a div draggable without relying on jQuery UI.
Here is the HTML code:
<div class="wrapper">
<div class="toddler"></div>
</div>
And here is the script I have written:
$.fn.slider = function () {
$(this).on("mousedown", function () {
$dragging = true;
});
$(this).on("mouseup", function () {
$dragging = null;
});
$(this).on("mousemove", function () {
if ($dragging) {
$(this).offset({
left: $(this).pageX
});
}
});
};
$(".toddler").slider();
You can view my work in this JSFiddle link.
However, despite my efforts, the code does not seem to be functioning correctly. Can anyone help me figure out what's wrong and how to make it work?