这个是在外国的论坛看到的解释
Contents of that jQuery object are plain DOM elements, which doesn't respond to jQuery methods (e.g. .attr). You need to wrap the value by $() to turn it into a jQuery object to use it.
大概的意思是说在each这个方法中的对象是普通的dom元素,不能对它直接使用jQuery的方法,解决方法有以下两个
把xxx.attr("id")改成$(xxx).attr("id");
直接用js的方法获取元素的属性值xxx.getAttribute("id");
第二个方法我试过是可行的,第一个方法还没有用过。