Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var id =0;
- class theObject{
- constructor(){
- this.id=id++;
- }
- writeOutput(){
- console.log("write output");
- $('<span>').appendTo('#output').html("id:"+id);
- }
- }
- var theObject1 = new theObject();
- var theObject2 = new theObject();
- $(document).ready(function(){
- theObject1.writeOutput();
- theObject2.writeOutput();
- })
- </script>
- <body>
- <div id="output"></div>
- </body>
- </html>
- $('<span>').appendTo('#output').html("id:" + this.id);
- // ------------------------------------------^^^^^
- writeOutput()
- {
- console.log("write output");
- $('<span>').appendTo('#output').html("id:"+this.id);
- }
Add Comment
Please, Sign In to add comment