【发布时间】:2012-12-07 18:29:58
【问题描述】:
我在一个 DIV 中有一些图像,带有一个水平滚动条 (jscrollpane)。
我首先获取所有图像的宽度并将该宽度分配给容器,但我想制作一个按钮来更改照片的高度(400px/600px)。当我单击按钮更改高度时,我还需要重新计算所有图像的宽度 - 这就是我的问题。
我的代码中的什么被破坏来计算图像的宽度并将其分配给 div?
我的代码:
$(window).load(function(){
$('.minus-button').click(function() {
//alert('clicked');
$(".scroll-content-item img, .scroll-content-item, .jspContainer").css('height', 200);
$('.scroll-content').each(function(){
var wrapper = $(this);
var wrapperWidth = 0;
wrapper.find('.scroll-content-item img').each(function(){
wrapperWidth += $(this).outerWidth(true);
});
wrapper.css('width', wrapperWidth);
});
});
});
有什么想法吗?谢谢你! 链接:http://bit.ly/TJaqC6
【问题讨论】:
-
请缩进以便阅读。
标签: jquery jquery-ui width jscrollpane