I have the following javascript:
var testObj = function() {
this.test1 = "123";
}
testObj.prototype = {
myFunc: function() {
var input = $('<input type=button value="clickme" />');
$('body').append(input);
input.click(function () {
alert(this.test1);
});
}
}
$(document).ready( function() {
var t = new testObj();
t.myFunc();
});
I know why the alert statement is showing undefined, but how do I make it show the actual value of test1 variable.
jsFiddle has the sample code.