[code]let map = {};$(\'.explain\').each(function() {var _id = $(this).attr(\"id\");var _value = $(this).val();if (_value !=\'\') {map[_id] = _value;}});let checkEmpty = $.isEmptyObject(map);alert(checkEmpty);
像上面那种写法,如果使用 map.length来判断,获取不到长度 ==> undefind;
使用 jQuery 自带函数处理即可,此方法也适用于其他场景。