Guest User

Untitled

a guest
Jul 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. main.js:4 Uncaught TypeError: $container.setBackgroundColor is not a function
  2.  
  3. window.onload = function () {
  4. var $container = new View("container");
  5.  
  6. $container.setBackgroundColor("#E9425B");
  7.  
  8. document.body.append($container);
  9. };
  10.  
  11. class View{
  12. constructor(id){
  13. this.id = id;
  14. this.view = document.createElement(this.id);
  15. return this.view;
  16. };
  17.  
  18. get(){
  19. return document.getElementsByTagName(this.id);
  20. };
  21.  
  22. setText(text){
  23. this.get().innerText = text;
  24. };
  25.  
  26. setBackgroundColor(color){
  27. this.get().style.backgroundColor = color;
  28. };
  29.  
  30. create(id){
  31. if(id != null){
  32. this.id = id;
  33. }
  34. };
  35.  
  36. addChild(child){
  37. console.log(child);
  38. this.get().append(child);
  39. };
  40. }
Add Comment
Please, Sign In to add comment