我使用此 jquery 代码根据 slider 上的阅读更多扩展内容确定高度
,每张幻灯片都有不同的阅读更多扩展内容的高度
。
这是我使用的代码:
$('#super-slideshow-2').height($('.slider_area').height() + 'px');
它在第一张幻灯片上效果很好,但是当我转到下一张幻灯片并单击“阅读更多”时,div
自行折叠。我现在真的不知道我能从这里做什么我还没有尝试过其他任何东西。有什么建议吗?
最佳答案
问题是您每次都获得第一个 .slider_area
的高度,在您离开后第一张幻灯片不再可见并且可能没有高度。您需要将每个索引匹配在一起。
$('#super-slideshow-2').height($('.slider_area').eq(index).height() + 'px');
index
是幻灯片的索引。我看不到您的代码,但我认为它与此类似:
var index = $('#super-slideshow-2 li.active').index();
其中 li.active
表示在屏幕上主动显示的幻灯片,假设 $('#super-slideshow-2')
是一个 ul/ol
关于jquery - 基于 slider 内容的 DIV 高度在下一张幻灯片上折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21314958/