how to create a Draggable element



how to create a Draggable element..

Answer / Dinesh Singh

You can use JavaScript libraries like jQuery UI or Dragula to make an element draggable. Here's an example using jQuery UI:n```htmln<!DOCTYPE html>n<html lang="en">n<head>n <meta charset="UTF-8">n <title>Draggable Example</title>n <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/theme.min.css">n <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>n <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>n</head>n<body>n <div id="draggable" class="draggable ui-widget-content">Drag me!</div>n <script>n $( function() {n $( "#draggable" ).draggable();n });n </script>n</body>n</html>```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Code Interview Questions

how to copy form data between different pages

1 Answers  


code to create a new window

1 Answers  


program to bring a window to the front

1 Answers  


how to get the User's Time of Day

1 Answers   HCL,


how to pass data between pages using URLs

1 Answers   Symantec,


write a function to validate a given date

1 Answers  


How to block double clicks

1 Answers  


i am making a purchase sheet in html ,it contain names of product(by selecting checkboxes),quantity(textbox) and price(checbox), by using java script i am restricting the user to prevent them to enter the wrong data ,so i made the servlet were i am only able to prevent them to enter the page in empty field , so my doubt is how do you prevent them how to enter non numerical data in quantity field

2 Answers   Infosys,


How to Add Message and Confirmation Boxes Using JavaScript?

1 Answers  


write a program to detect the user's browser ?

1 Answers   Infosys,


how to create an anonymous function

1 Answers  


program that will accept any name and will be stored in an array

2 Answers  


Categories
  • PHP Code Interview Questions PHP Code (33)
  • JSP Code Interview Questions JSP Code (6)
  • ASP Code Interview Questions ASP Code (5)
  • CGI Perl Code Interview Questions CGI Perl Code (3)
  • JavaScript Code Interview Questions JavaScript Code (63)
  • VB Script Code Interview Questions VB Script Code (20)
  • Shell Script Code Interview Questions Shell Script Code (31)
  • Python Code Interview Questions Python Code (34)
  • WinRunner Code Interview Questions WinRunner Code (1)
  • HTML DHTML XHTML Code Interview Questions HTML DHTML XHTML Code (13)
  • XML Interview Questions XML (43)
  • Scripts_Markup Code AllOther Interview Questions Scripts_Markup Code AllOther (5)