【发布时间】:2010-02-15 23:24:46
【问题描述】:
当我在 JS 或 jQuery 中编写函数并且需要参数时,我使用 if something.length 技巧...
this.example = function(e) {
if ($(e).length) {
/*blablabla*/
} else {
return false;
}
}
但我不想在所有功能中都这样做。有没有办法概括这一点?
喜欢:
this.ck = function(e) {
return function(e){
if (!(e.length)) { return false;}
}
}
this.example = function(e) {
ck(e)
/*blablabla*/
}
【问题讨论】:
标签: jquery