function prototype(id){ this.ID = id; this.CrearDiv = function CrearDivs(){ var ID = this.ID; var Capa = document.getElementById('espacioPrueva'); var DivPrueva = document.createElement('div'); DivPrueva.style.width = 200+'px'; DivPrueva.style.height = 200+'px'; DivPrueva.style.margin = '10px 10px'; DivPrueva.style.background = 'hsla(120,100%,50%,1)'; Capa.appendChild(DivPrueva); DivPrueva.addEventListener("mouseover", function (){ document.getElementById('log').innerHTML ='ObjetoPrueva ' +ID; }, false); } } var ObjetoPruevaUno = new prototype(1); ObjetoPruevaUno.CrearDiv(); var ObjetoPruevaDos = new prototype(2); ObjetoPruevaDos.CrearDiv();