Tag: jquery animate

你如何为jQuery UI进度条设置animation值?

我已经设置了一个jQuery UI进度条,但不能使用jQueryanimation来为其设置animation值。 任何想法如何使这项工作? percentDonevariables包含一个从0到100的数字,表示滚动条应该有多远(这个工作正常)。 我尝试了几个不同的东西,无济于事。 以下是我到目前为止: var progressbar = $("#progressbar1").widget(); progressbar.animate({ value: percentDone }, 5000, function() { console.debug('done animating'); }); 请注意,如果我使用“值”方法更新滚动条,它可以正常工作,但是会跳转到该值,而不是平滑地进行animation: $("#progressbar1").progressbar('value', percentDone);

使用jQuery .animate从右到左animationdiv?

我有一个绝对定位在top: 0px的div top: 0px和right: 0px ,我想使用jquery的.animate()从它的当前位置left: 0pxanimationleft: 0px 。 如何做到这一点? 我似乎无法得到这个工作: $("#coolDiv").animate({"left":"0px"}, "slow"); 为什么不这样做,以及如何做到我期望做的事情? 谢谢!!

jQuery的$ .animate()多个元素,但只消防一次callback

如果您select一个类或元素的集合来使用jQuery进行animation处理: $('.myElems').animate({….}); 然后也使用callback函数,你最终会有很多不必要的animate()调用。 var i=1; $('.myElems').animate({width:'200px'}, 200, function(){ //do something else $('#someOtherElem').animate({opacity:'1'}, 300, function(){ if (i>1) console.log('the '+i+'-th waste of resources just finished wasting your resources'); i++; }); }); 可以说这只是不好的代码和/或devise – 但是有一些我可以做的事情,都避免了使用callback只有一个有很多animate()调用,并有一个不必要的callback负载执行和拧我的代码/预期的行为? 理想情况下,我只能编写一个只能运行一次的“一次性”callback – 否则可能有一种有效的方法来testing是否已经由jQueryanimation? 例如: http : //jsfiddle.net/uzSE6/ (警告 – 这将显示一个警报框的负载)。

jquery prepend + fadeIn

我有这个代码: $.ajax({ url : url, data : {ids : JSON.stringify(jsonids), hotel_id: hotel_id}, success : function(response) { $('#be-images ul').prepend(response).fadeIn('slow'); }, dataType: 'html' }); 但淡入在不工作…我想要的内容前置和淡入…我将如何做到这一点? 提前致谢!

你怎么褪色和同时animation?

使用jQuery我创build了一个基本的“工具提示”animation,这样工具提示就会出现在一个小的animation中,在这个animation中,它可以淡入视图,也可以垂直移动。 到目前为止,我有这样的: $('.tooltip').fadeIn('slow'); $('.tooltip').animate({ top: "-10px" }, 'slow'); 这样做或这样做: $('.tooltip').fadeIn('slow').animate({ top: "-10px" }, 'slow'); animation将一次运行一个,首先淡入,然后是垂直animation。 有没有办法让它在同一时间?

在jQuery中旋转Div元素

试图旋转一个div元素…这可能是DOM亵渎,它可以工作可能与canvas元素? 我不确定 – 如果任何人有任何想法可以工作或为什么不这样做,我很想知道。 谢谢。

用jquery.animate()交叉浏览CSS

我正在创build一个跨浏览器兼容的旋转(ie9 +),我有一个jsfiddle下面的代码 $(document).ready(function () { DoRotate(30); AnimateRotate(30); }); function DoRotate(d) { $("#MyDiv1").css({ '-moz-transform':'rotate('+d+'deg)', '-webkit-transform':'rotate('+d+'deg)', '-o-transform':'rotate('+d+'deg)', '-ms-transform':'rotate('+d+'deg)', 'transform': 'rotate('+d+'deg)' }); } function AnimateRotate(d) { $("#MyDiv2").animate({ '-moz-transform':'rotate('+d+'deg)', '-webkit-transform':'rotate('+d+'deg)', '-o-transform':'rotate('+d+'deg)', '-ms-transform':'rotate('+d+'deg)', 'transform':'rotate('+d+'deg)' }, 1000); } CSS和HTML非常简单,只是为了演示: .SomeDiv{ width:50px; height:50px; margin:50px 50px; background-color: red;} <div id="MyDiv1" class="SomeDiv">test</div> <div id="MyDiv2" class="SomeDiv">test</div> 使用.css()时旋转工作,但在使用.animate()时.animate() 。 为什么是这样的,有没有办法解决它? 谢谢。

jQuery .scrollTop(); +animation

当单击button时,我将页面设置为滚动到顶部。 但是,首先我使用if语句来查看页面顶部是否未设置为0.然后,如果不是0,则使页面动起来滚动到顶部。 var body = $("body"); var top = body.scrollTop() // Get position of the body if(top!=0) { body.animate({scrollTop:0}, '500'); } 现在棘手的部分是animation页面滚动到顶部后的东西。 所以我的下一个想法是,找出页面的位置是什么。 所以我使用控制台日志来查明。 console.log(top); // the result was 365 这给了我365的结果,我猜这是我在滚动到顶部之前的位置号。 我的问题是如何将位置设置为0,以便我可以添加另一个页面在0时运行的animation? 谢谢!

JavaScript jQueryanimation到自动高度

我想animation从200px到自动高度的div。 我似乎不能使它工作 – 任何人都知道如何? 代码如下: $("div:first").click(function(){ $("#first").animate({ height: "auto" }, 1000 ); });

在页面加载时滚动滚动到ID

在页面加载时,要将滚动设置为特定的ID。 我做了大量的研究,碰到这个: $("html, body").animate({ scrollTop: $('#title1').height() }, 1000); 但是这似乎是从ID开始的,并在页面顶部生成animation? HTML(这是页面的一半)很简单: <h2 id="title1">Title here</h2>