I don't see where you are calling any of your functions or setting selector. However, one problem is that the formal function parameter selector in your definition of $ masks the outer variable also named selector. If you eliminate the function parameter, it should work better (assuming that you are also somewhere setting selector):
var selector; //id of html element
function $()
{
if(window===this)
return new $(selector);
return this;
}
$.prototype={
tooltip: function(){
console.log(selector);
//do calculations with the selector value
return this;
}
};
The way your code is written now, it is as if it were written as follows:
var selector; //id of html element
function $(x)
{
if(window===this)
return new $(x);
return this;
}
$.prototype={
tooltip: function(){
console.log(selector);
//do calculations with the selector value
return this;
}
};
.tooltip?