;(function($){
$.extend({
isEmpty: function(obj){
var rs = true;
var type = $.type(obj);
switch (type) {
case "string":
obj = $.trim(obj);
rs = (obj.length==0)?true:false;
break;
case "number":
rs = (obj==NaN)?true:false;
break;
case "boolean":
rs = false;
break;
case "object":
rs = (Object.keys(obj).length==0)?true:false;
break;
case "array":
rs = obj.length==0?true:false;
break;
default:
break;
}
return rs;
},
isNotEmpty: function(obj){
return !$.isEmpty(obj));
},
isNull: function(obj){
return (obj==undefined || obj==null || ($.type(obj)=="string" && obj.toLowerCase()=="null") )?true:false;
}
});
})(jQuery);
jquery 自定义空值判断插件
最新推荐文章于 2022-12-29 08:49:17 发布