为什么这个.each函数运行错误

0 javascript jquery html5

我有这个功能来打印所有<img>具有属性的图像尺寸[proto].

当我使用此each方法尝试该函数时,它只返回一个函数.

这是什么错误?

function size(){
    var $img = $('img[proto]');
    $($img).each(function(){
        var height = $(this).height;
        var width = $(this).width;
        $(this).parent().find('p').remove();
        $(this).parent().append('<p class="size">' + width + '-' + height + '</p>');

    });
}
size();
Run Code Online (Sandbox Code Playgroud)

Mou*_*faS 8

这些功能不是属性,高度和宽度:

var height = $(this).height();
var width = $(this).width();
Run Code Online (Sandbox Code Playgroud)