我一直认为jQuery中应该有一个.id而不是.attr('id')。问:如何编写插件,以便myObject.id返回myObject.attr('id')? 最佳答案 为了争辩,这里是您的处理方式。// extend jQuery object with your id $.fn.id = function() { // return the id of the first DOM element. return this[0].id; }