为每个具有不同变量的多个已加载元素声明height()
个变量后,animate()
函数似乎无法加载变量excHeight
。
对excHeight
使用animate()
的值的最佳方法是什么?
$(".exPand a").click(function (event) {
event.preventDefault();
var post_id = $(this).attr("rel");
var postHeight = $(this).closest('.boxy')
.find('.articleImageThumb')
.height();
var excHeight = $(this).closest('boxy')
.find('.articleImageThumb')
.find('.initialPostLoad')
.height();
$.ajaxSetup({cache:false});
$(this).closest('.boxy')
.animate({height: postHeight+excHeight}, 1000);
$(this).closest('.boxy')
.find('.articleImageThumb')
.animate({top: 0}, 1000);
$(this).closest('.boxy').find('.articleTitle')
.animate({bottom: excHeight}, 1000);
$(this).closest('.boxy').find('.postmetadata')
.animate({bottom: excHeight}, 1000);
});
答案 0 :(得分:4)
似乎因为忘记boxy
班级名称中的“点”而无法正常工作:var excHeight = $(this).closest('boxy')
,必须如下:var excHeight = $(this).closest('.boxy')