基本问题,我是 jQuery 新手,这行不通。
基本上,我试图使 div (top_bar) 从宽度 0% 开始,然后加宽到宽度 76%。当我打开页面时,该栏不存在(由于初始宽度为 0%)
这是我的基本想法。我只是不知道该将什么作为 animate() 的参数。
$(document).ready(function() {
$('#top_bar').animate({$('#top_bar').width:"76%"}, 1000);
});
最佳答案
您的语法不正确。 animate()
的第一个参数采用具有您要设置的样式的对象,而不是选择器:
$(document).ready(function() {
$('#top_bar').animate({width:"76%"}, 1000);
});
关于jquery - 在 jQuery 中获取一个在屏幕上滚动的栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16422894/