【发布时间】:2013-01-10 23:28:27
【问题描述】:
通过在这里解决所有类似的问题,我对我的 jQuery 动画持续时间失败的代码有疑问。我的目的是使用 ajax 从 DB 中提取长内容并填充 div,然后将 div 扩展到适当的高度。非常欢迎您指出我的理论中任何不足之处。但是当回到持续时间失败时,它根本不起作用,我找不到原因。
$('.button_expand_news').click(function() {
$(this).text('LOADING...');
var pod = $(this).prev();
var id = $(this).attr('id');
$.ajax({
url: 'func.blogs.php?p=loadNews&id=' + id,
dataType: 'json',
success: function(response) {
var content = response['full_content'];
pod.html('');
pod.html(content);
pod.animate({
height: '100%'
}, 500, function() {
$(this).next().text('COLLAPSE');
});
}
});
}
演示页面可以参考my project site。
【问题讨论】:
-
您意识到您的测试站点将动画持续时间设置为 0 对吗? tiams.0zed.com/lib/news.js
-
是的 Rick,即使持续时间设置为 1000,它也不起作用。所以我将其设置为零以节省系统资源。
标签: jquery jquery-animate duration