jac*_*ack 0 each jquery image dimensions
我正在尝试编写一些代码来打印div中包含的所有图像的尺寸,这很简单,因为它似乎无法让它工作.有人能指出这里的错误吗?谢谢!
$(document).ready(function() {
var width = 0;
var height = 0;
var hello = "hello";
$('#imagebox img').each(function(){
width = $(this).width;
height = $(this).height;
$('#main').append(hello);
$('#main').append(width);
$('#main').append(height);
});
});
Run Code Online (Sandbox Code Playgroud)
宽度和高度是功能.尝试:
width = $(this).width();
height = $(this).height();
Run Code Online (Sandbox Code Playgroud)