function cat() {
this.getMyID = function() { alert(this.id); } ;
}
var bob = new cat();
// I want it to say 'bob'
bob.getMyID();
alerts undefined, any ideas?
I'll elaborate, this is what I want to do - insert into an onclick method of a button something that calls another function, eg:
function cat() {
this.render = function() { $('#myButton').attr('onclick', 'this.meow()'); };
}
var bob = new cat();
bob.render();
However this will fail because 'this.meow' is nonsense. If I knew the ID, ie. bob, then I could change it to do .attr('onclick', theID + '.meow()'); };