我想向下滑动元素,它的持续时间必须取决于高度。例如,如果高度为2000px,持续时间也必须为2000
这是我的js
var element = document.getElementById('detail-'+thisID),
style = window.getComputedStyle(element),
content_height = style.getPropertyValue('height');
var height_js=parseInt(content_height, 10);
$('#wrap #detail-'+thisID).delay(700).slideDown(height_js);
我走对了吗?如果是,错误在哪里?
如果你已经在使用jquery,你可以使用jquery .height:
$('#wrap #detail-'+thisID).delay(700).slideDown($('#wrap #detail-'+thisID).height());
同样,在你的代码中,你应该只使用document.getElementById('detail-'+thisID')
,不带后面的#
,这只是一个jquery选择器,用于识别应该通过Id搜索的元素。