dir.by  
  Search  
Programming, development, testing
jQuery UI - buttons, menus, dialog, slider, spinner and so on. Effects: stretching, dragging, and so on
Draggable (the item can be moved with the mouse) jQuery UI
  Looked at 6566 times       Comments 2  
 Last Comment: (11 December 2018 15:56) в этой теме рассматривается 2 примера: [bgcolor=orange]1)[/bgcolor]... read...       Write a comment...
 Draggable (the item can be moved with the mouse) jQuery UI 
last updated: 5 February 2020
Method draggable in the jQuery UI allows you to move an item with the mouse.
Example we look, we test
Example code
  Html  
<html>

<!-- heading -->
<head>
     <meta charset="utf-8">
     <title>Example</title>
</head>

<!-- page -->
<body>
     <!-- connect libraries jQuery and jQuery UI -->
     <script src="https://dir.by/example_lib/jquery/jquery-3.3.1.min.js"></script>
     <script src="https://dir.by/example_lib/jquery_ui/jquery-ui-1.12.1/jquery-ui.min.js"></script>

     <!-- HTML Elements -->
     <div id="myElement" style="height:150px; width:150px; cursor:hand; background:#b0b0b0;">
          Click on me and drag me with your mouse
     </div>

     <!-- JavaScript -->
     <script>
          // the page has opened
          $( function()
          {
               // call the method draggable so that he can drag and drop myElement
               $("#myElement").draggable();
          });
     </script>
</body>

</html>
Note!
The example works locally!

Run the example on your computer:
1) Create a new file my.html
2) Copy source code in the my.html file
3) Run in browser my.html

By the way!
The example allows you to drag and drop onto your computer.
Example does not allow you to drag and drop on mobile devices (smartphones, tablets).
Drag and drop on mobile devices (smartphones, tablets)
Example we look, we test
Explanation
One line is added to the code, this is the connection of the library jQuery UI Touch Punch ... to drag and drop on tablet, phone.
  Html  
<script src="https://dir.by/example_lib/touch-punch/jquery.ui.touch-punch.js"></script>


All example code to drag and drop on tablet, phone
In the code, the added line is highlighted Blue.
  Html  
<html>

<!-- heading -->
<head>
     <meta charset="utf-8">
     <title>Example</title>
</head>

<!-- page -->
<body>
     <!-- connect libraries jQuery and jQuery UI -->
     <script src="https://dir.by/example_lib/jquery/jquery-3.3.1.min.js"></script>
     <script src="https://dir.by/example_lib/jquery_ui/jquery-ui-1.12.1/jquery-ui.min.js"></script>

     <!-- drag-and-drop library for tablet, phone -->
     <script src="https://dir.by/example_lib/touch-punch/jquery.ui.touch-punch.js"></script>

     <!-- HTML Elements -->
     <div id="myElement" style="height:150px; width:150px; cursor:hand; background:#b0b0b0;">
          Click on me and drag me with your mouse
     </div>

     <!-- JavaScript -->
     <script>
          // the page has opened
          $( function()
          {
               // call the method draggable so that he can drag and drop myElement
               $("#myElement").draggable();
          });
     </script>
</body>

</html>
 
← Previous topic
jQuery UI where to download and how to connect?
 
Next topic →
Droppable (a dragged item can be thrown) jQuery UI
 
Your feedback ... 1 Comments
guest
10 December 2018 23:15
не работает на windows планшете. только что проверил
admin (11 December 2018 15:56) в этой теме рассматривается 2 примера:

1) пример для браузера используя мышь: example1

2) пример для планшетов: example2

Вы проверили последний пример?
answer
   
Your Name
Your comment (www links can only be added by a logged-in user)

  Объявления  
  Объявления  
 
What the JQuery UI ?
jQuery UI where to download and how to connect?
Interactions (interaction)
Draggable (the item can be moved with the mouse) jQuery UI
Droppable (a dragged item can be thrown) jQuery UI
Resizable (resize an item with the mouse) jQuery UI
Selectable (select one or more elements with the mouse) jQuery UI
WWW sites to explore JQuery UI
Sites to explore JQuery UI

  Ваши вопросы присылайте по почте: info@dir.by  
Яндекс.Метрика