JQuery/javascript how do I get the ID of an object?
<pre><code>function cat() {


    this.getMyID = function() { alert(this.id); } ;

}

var bob = new cat();

// I want it to say 'bob'
bob.getMyID();
</code></pre>

<p><a href="http://jsfiddle.net/n7eHj/" rel="nofollow">http://jsfiddle.net/n7eHj/</a></p>

<p>alerts undefined, any ideas?</p>

<p>I'll elaborate, this is what I want to do - insert into an onclick method of a button something that calls another function, eg:</p>

<pre><code>function cat() {

   this.render = function() { $('#myButton').attr('onclick', 'this.meow()'); };

}

var bob = new cat();
bob.render();
</code></pre>

<p>However this will fail because 'this.meow' is nonsense. If I knew the ID, ie. bob, then I could change it to do <code>.attr('onclick', theID + '.meow()'); };</code></p>
