Java-script object - get variable name
- by Mikk
Hi,
To begin with, I'm not even sure, if it is the right way to do it.
Let's say, i have script (jquery included) like this:
foo = function() {
this.bar = function() {
alert('I\'m bar');
}
this.test = function() {
$('body').append('<a onclick="my_var.bar();">Click me</a>');
}
this.test();
}
var my_var = new foo();
Is there any way, i could make variable "my_var" dynamic inside function "foo".
So I could do something like
$('body').append('<a onclick="'+the_variable_which_im_assigned_to+'.bar();">Click me</a>');
Thank you