Advertisement
idroj07

aclarando metodos en objetos js

Nov 22nd, 2019
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     //ESTA METODO FUNCIONA , REALIZA UNA ACCION EN EL DOM AL LLAMARLO
  2. function mostrar() {
  3.             document.write("<h2>Titulo: "+this.titulo+"</h2>");
  4.             document.write("<h2>Grupo: "+this.grupo+"</h2>");
  5.             document.write("<h2>Fecha: "+this.año+"</h2>"+"<br><br>");
  6.         }
  7.         function cd_musica(titulo,grupo,año) {
  8.             this.titulo = titulo;
  9.             this.grupo = grupo;
  10.             this.año = año;
  11.             this.mostrar = mostrar;
  12.         }
  13.  
  14.  
  15.  
  16.  
  17.     // NO FUNCIONA DEVUELVE UN VALOR A UNA PROPIEDAD (NO SE LLAMARIA DESDE FUERA DEL OBJ, solo usa la func par coger un valor)
  18.  
  19. function getColor() {
  20.     if (!this.disponible) {
  21.         return "red";
  22.     }else{
  23.         if (this.selec) {
  24.             return "green";
  25.         }else{
  26.             if (this.tipo == "mesaM") {
  27.                 //return "#a05a2c";
  28.                 return "purple";
  29.             }else
  30.                 return "#ffd42a";
  31.         }
  32.     }
  33. }  
  34. function Elemento(tipo,id,disponible,genCod,selec,tag) { //tag es por REFERENCIA o por valor?
  35.     this.tipo = tipo;
  36.     this.id = id;
  37.     this.disponible = disponible;
  38.     this.genCod = genCod;
  39.     this.selec = selec;
  40.     this.changeColor = getColor;
  41.     this.tag = tag;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement