jjzjj

applyWidth

全部标签

javascript - jQuery 集合、功能和组织

我有以下代码,它获取单个图像并为其应用特定宽度:functionFoo(img){this.image=img;}Foo.prototype._getWidth=function(){returnthis.image.data('largest')+'px';};Foo.prototype.applyWidth=function(){this.image.css('width',this._getWidth());};varimg=Foo($('img'));img.applyWidth();然而,我正在努力处理jQuery图像集合,例如没有for循环的$('img')或$.each(