Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Singleton(){
- this.list = new Array();
- this.getList = function(){
- }
- this.add = function(num){
- this.list.push(num);
- }
- this.print = function(){
- $.each(this.list,function(i,o){
- console.log(o);
- });
- }
- }
- <script src='jquery-1.11.1.min.js'></script>
- <script src='singleton.js'></script>
- <script type='text/javascript'>
- var list;
- function insert(){
- var num = $('#number').val();
- list.add(num);
- list.print();
- }
- $(document).ready(function(){
- list = new Singleton();
- });
- </script>
- <body>
- <input type='text' id='number'/> <input type='button' value='Insert' onclick='insert()'/>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement