Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Sortable Placeholder</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script> <style> #list{list-style:none;margin:0;padding:0;width:220px;} #list li{margin:0 0 6px 0;padding:0.5em 1em;background:#f4f4f4;border:1px solid #ccc;cursor:move;} .ui-state-highlight{height:1.8em;line-height:1.2em;background:#fff3d6;border:1px dashed #f6c343;} </style> </head> <body> <p>Drag an item — notice the dashed placeholder showing where it will drop.</p> <ul id="list"> <li class="ui-widget-content">Item 1</li> <li class="ui-widget-content">Item 2</li> <li class="ui-widget-content">Item 3</li> <li class="ui-widget-content">Item 4</li> </ul> <script> $(function(){ $("#list").sortable({ placeholder: "ui-state-highlight" }); }); </script> </body> </html>
Output