Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Selectable Icon Grid</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> #icon-grid{list-style:none;margin:0;padding:0;width:320px;overflow:hidden;} #icon-grid .icon{float:left;width:80px;height:80px;margin:6px;text-align:center;padding:6px;background:#f4f4f4;border:1px solid #ccc;border-radius:4px;font-size:12px;} #icon-grid .icon i{display:block;font-size:28px;margin-bottom:6px;} #icon-grid .ui-selecting{background:#fff3d6;} #icon-grid .ui-selected{background:#04AA6D;color:#fff;} </style> </head> <body> <p>File-manager style: drag a box or click icons to select files.</p> <ul id="icon-grid"> <li class="icon">📄 file1.txt</li> <li class="icon">📄 file2.txt</li> <li class="icon">📁 folder1</li> <li class="icon">📄 file3.txt</li> <li class="icon">📁 folder2</li> <li class="icon">📄 file4.txt</li> </ul> <script> $(function(){ $("#icon-grid").selectable({ filter: '.icon' }); }); </script> </body> </html>
Output