ivana_andreevska

List Builder

Dec 23rd, 2021
1,232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.32 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Title</title>
  6.     <link rel="stylesheet" href="jquery-ui.css">
  7.     <script src="jquery.js"></script>
  8.     <script src="jquery-ui.js"></script>
  9.  
  10.     <style>
  11.         ul{
  12.             width: 250px;
  13.             cursor: pointer;
  14.             display: inline-block;
  15.             list-style-type:none;
  16.             vertical-align: top;
  17.         }
  18.         li{
  19.             border:1px solid gray;
  20.             margin-bottom: 5px;
  21.             padding:5px;
  22.         }
  23.         .ui-selected{
  24.             background-color: #b81900;
  25.         }
  26.     </style>
  27. </head>
  28. <body>
  29. <ul id="source" class="selected">
  30.     <li>Item 1</li>
  31.     <li>Item 2</li>
  32.     <li>Item 3</li>
  33.     <li>Item 4</li>
  34.     <li>Item 5</li>
  35.     <li>Item 6</li>
  36.     <li>Item 7</li>
  37. </ul>
  38. <button id="add"> > </button>
  39. <button id="remove"> < </button>
  40.  
  41. <ul id="dest" class="selectable">
  42.     <li>Item 8</li>
  43. </ul>
  44. <script src="main.js">
  45. </script>
  46. </body>
  47. </html>
  48.  
  49. $(document).ready(function (){
  50.  $(".selected").selectable();
  51.  $("#add").click(function (){
  52.      $("#source").find(".ui-selected").appendTo("#dest").removeClass("ui-selected")
  53.  })
  54.     $("#remove").click(function (){
  55.         $("#dest").find(".ui-selected").appendTo("#source").removeClass("ui-selected")
  56.     })
  57. })
  58.  
  59.  
  60.  
Advertisement
Add Comment
Please, Sign In to add comment