我有下一个功能:
function setImagesWidth(id,width) {
var images = document.getElementById(id).getElementsByTagName("img");
for(var i = 0; i < images.length;i++) {
// If the real width is bigger than width parameter
images[i].style.width=width;
//}
}
}
我想只在图像实际宽度大于属性值时才将所有img标签的css width属性设置为特定值.如果可能的话,我想要一个不使用任何特定框架的解决方案.
images [i] .offsetWidth为109px宽度的图像返回111.这是因为每边边界1px?