Skip to content

Instantly share code, notes, and snippets.

@jaywon
Created August 8, 2014 06:26
Show Gist options
  • Save jaywon/606e946fcd1d7850484b to your computer and use it in GitHub Desktop.
Save jaywon/606e946fcd1d7850484b to your computer and use it in GitHub Desktop.
//Main Class
//Create base div class
function Div(){
this.color = null;
this.htmlElement = null;
this.draw = function (){
this.htmlElement = $("<div>"+this.color+"</div>");
$('body').append(newDiv);
}
}
@jaywon
Copy link
Author

jaywon commented Aug 8, 2014

Changed the locally scoped variable var newDiv to class attribute this.htmlElement. This stores a reference in your class to you actual HTML element that you created in the DOM.

@alexconway808
Copy link

OK, so the way this works is that instead of creating a newDiv var you instead want to create an attribute of the Div class, which is the this.htmlElement, and then I can use that attribute in other sub classes of Div?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment