我想要的功能,这样的库(类似于jQuery是做)的JavaScript返回默认值
var myLib = function (idOfAnElement){
var myElement = document.getElementById(idOfAnElement);
return{
getHeight: function(){
return myElement.style.height;
},
getWidth: function(){
return myElement.style.width;
}
}
}
我的问题是,我不知道怎么回
myElement
在默认情况下,如果没有所谓的喜欢
myLib('myId').getHeight; // Returns Height
myLib('myId') // Is supposed to return the HTML-Element with id = 'myId'
你尝试过什么吗? – fcalderan 2014-11-13 11:20:18