Gregor Gregor - 1 year ago 63
Javascript Question

Why is this .each function working wrong

i have this function to print the image size of all having the

attribute [proto]

When i try it with this
method, its only giving back a function.

Where is my mistake? Please help.

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


Answer Source

These are functions not properties, height and width:

var height = $(this).height();
var width = $(this).width();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download