Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. function Singleton(){
  2. this.list = new Array();
  3.  
  4. this.getList = function(){
  5.  
  6. }
  7.  
  8. this.add = function(num){
  9. this.list.push(num);
  10. }
  11.  
  12. this.print = function(){
  13. $.each(this.list,function(i,o){
  14. console.log(o);
  15. });
  16. }
  17. }
  18.  
  19. <script src='jquery-1.11.1.min.js'></script>
  20. <script src='singleton.js'></script>
  21. <script type='text/javascript'>
  22.  
  23. var list;
  24.  
  25. function insert(){
  26. var num = $('#number').val();
  27. list.add(num);
  28. list.print();
  29. }
  30.  
  31. $(document).ready(function(){
  32. list = new Singleton();
  33. });
  34. </script>
  35. <body>
  36. <input type='text' id='number'/> <input type='button' value='Insert' onclick='insert()'/>
  37. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement