Edit in JSFiddle

$(document).ready(function(){
    
    var i = 1;
    var arr = new Array();
    for (i=1;i<=10;i++){
        var randx = Math.round(Math.random()*50) * i;
        var randy = Math.round(Math.random()*100);
        var a = new Box (randx,randy,'#FF0000',i,'body');
        arr.push(a);
        
    }
    
    arr[1].setPos(100,200);

    function Box(x,y,clr,i,parent){
        var a = this;
        this.id="box"+i;
        this.x = x;
        this.y = y;
        this.clr = clr;
        
        $(parent).append('<div id="'+this.id+'"></div>');
        this.el=$("#"+this.id);
        var tmp = this.el;
        tmp.css({"position":"absolute","top":this.y, "left":this.x,"height":50, "width":50, "border":"1px solid "+this.clr});
        
        this.setPos = function(x,y){
            tmp.css({"top":x, "left":y, "border":"2px solid black"});
        }
        return  this;
    };
    
});