Advertisement
karlhillx

Untitled

Jul 23rd, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <style>
  2. .list {
  3. font-family: sans-serif;
  4. }
  5.  
  6. td {
  7. padding: 10px;
  8. border: solid 1px #eee;
  9. }
  10.  
  11. input {
  12. border: solid 1px #ccc;
  13. border-radius: 5px;
  14. padding: 7px 14px;
  15. margin-bottom: 10px
  16. }
  17.  
  18. input:focus {
  19. outline: none;
  20. border-color: #aaa;
  21. }
  22.  
  23. tbody.list tr:first-child {
  24. display: none;
  25. }
  26. </style>
  27.  
  28. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.2.0/list.min.js"></script>
  29.  
  30. <button id="add">
  31. Add
  32. </button>
  33. <div id="users">
  34.  
  35. <table>
  36. <!-- IMPORTANT, class="list" have to be at tbody -->
  37. <tbody class="list">
  38. <tr>
  39. <td style="display:none;"><input class="id" type="hidden"></td>
  40. <td><input class="name"></td>
  41. <td><input class="born"></td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46.  
  47. <script>
  48. $(document).ready(function () {
  49. var options = {
  50. valueNames: [
  51. {attr: 'value', name: 'id'},
  52. {attr: 'value', name: 'name'},
  53. {attr: 'value', name: 'born'},
  54. ]
  55. };
  56.  
  57. var userList = new List('users', options);
  58.  
  59. $("#add").on("click", function () {
  60. userList.add({
  61. id: Math.floor(Math.random() * 9) + 1,
  62. name: "Gustaf Lindqvist",
  63. born: 1983,
  64. count: 1,
  65. });
  66. });
  67. });
  68. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement