Guest User

Untitled

a guest
Jun 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <script type="text/javascript">
  2. var id =0;
  3. class theObject{
  4. constructor(){
  5. this.id=id++;
  6. }
  7. writeOutput(){
  8. console.log("write output");
  9. $('<span>').appendTo('#output').html("id:"+id);
  10.  
  11. }
  12. }
  13.  
  14. var theObject1 = new theObject();
  15. var theObject2 = new theObject();
  16.  
  17. $(document).ready(function(){
  18.  
  19. theObject1.writeOutput();
  20. theObject2.writeOutput();
  21. })
  22.  
  23.  
  24. </script>
  25. <body>
  26. <div id="output"></div>
  27.  
  28. </body>
  29. </html>
  30.  
  31. $('<span>').appendTo('#output').html("id:" + this.id);
  32. // ------------------------------------------^^^^^
  33.  
  34. writeOutput()
  35. {
  36. console.log("write output");
  37. $('<span>').appendTo('#output').html("id:"+this.id);
  38. }
Add Comment
Please, Sign In to add comment