Object reference to itself
<p>I'm not sure how to state this question correctly, but I am trying to create a javascript object which handles an array of images so that they can be reordered/moved around.</p>

<pre><code>function imgHandler(divname) {
    this.imgDiv = divname;
    this.img = Array("bigoldlizard.png","scarytiger.gif");
    this.update = function() {
        var htmlstr = "";
        for(i=0; i&lt;this.img.length; i++) {

//This is the line in question:
        htmlstr += "&lt;img src=\"" + this.img[i] + "\" onclick=\"javascript:" + ??? + ".remove(" + i + ")\"/&gt;&lt;/span&gt;";

        }
        $("#" + this.imgDiv).html(htmlstr);
    }

    //remove an image from the array
    this.remove = function(index) {
        if (index &gt;= 0 &amp;&amp; index &lt; this.img.length) {
            this.img.splice(index, 1);
            this.update();
            return true;
        }
        else
            return false;
    }
}
</code></pre>

<p>So basically, I need the object to be able to add its own name, or be able to reference itsself...</p>
