The code looks like this
function Scripts() {this.FindById = function (id) {
this.FindById.constructor.prototype.value = function () {
return document.getElementById(id).value;
}}}
var Control = new Scripts();
Now when i say Control.FindById(“T1”).value(). I am not able to get the textInput(“T1”)’s value.
It seems that your code is a bit more complicated then it should be 😉
Personally I would write it this way (not tested):
The
findById()now closes over a node and returns an interface that can return its value.Also, your idea sounds a lot like Singleton, so you wouldn’t even need the extra
Scriptsconstructor:Working example: http://jsfiddle.net/YYkD7/