jQuery Tutorial
In jquery, we can make any DOM element draggable which means moving DOM element in browser to any locations.
If we want to make any element is draggable, need to enable draggable functionality to that element.
Move the draggable element by clicking on it with the mouse and dragging it anywhere in the browser.
$(selector).draggable();
This jQuery code is used to enable div element draggable which can be moved anywhere in the browser.
here div element is selected using id 'divTitle' and enabled as draggable.
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>jQuery draggable method</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#divTitle").draggable(); }); </script> </head> <body> <div id="divTitle" style="height:200px;width:200px;background-color:blue;color:white;"> div element draggable testing! </div> </body> </html>Output:
draggable div element
After moving the draggable div element
jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page