jquery-animate

jQuery reverse animation on click

爱⌒轻易说出口 提交于 2020-01-14 04:14:09
问题 Looked through a few of the existing questions and they helped me get this far, but still cannot get it working. $('#languageSelctor').click(function() { $('#languageList').toggle(function() { $(this).animate({"top": "20px"},500); }, function() { $(this).animate({"top": "-100px"},500); }); }); Managed to put together the above code, but now it just does not work. So when someone clicks on languageSelctor, languageList needs to appear and then disappear if they click on languageList again. 回答1

How does JQuery do animations?

China☆狼群 提交于 2020-01-12 19:05:15
问题 JQuery is written in Javascript. As someone who knows a little of each, I have to wonder how they wrote some of it. How do you animate HTML elements in pure Javascript? Is it just repeatedly updating the CSS property that is to be animated, using standard DOM manipulation, with callbacks to make it asynchronous? Or is it something more sophisticated? 回答1: jQuery animations are just updating CSS properties on a recurring timer (which makes it asynchronous). They also implement a tweening

How to Add Auto-Rotation to a jQuery Horizontal Accordion

落爺英雄遲暮 提交于 2020-01-11 13:36:27
问题 I've built a horizontal accordion that animates on click. I want to add auto-rotating functionality to it so the slides will rotate by themselves every three seconds but i cannot figure this part out... Here is the code for the Horizontal Accordion: <div id="slideshow"> <ol id="slides"> <li class="slide open active" id="slide-1"> <a href="recipe_detail.aspx?did=1014"><img src="media/images/recipes/featured-tuna-chop-chop-salad.jpg" alt="" /></a> <a class="slidebutton" href="javascript:void(0)

jQuery animate to transparent

倾然丶 夕夏残阳落幕 提交于 2020-01-11 08:24:46
问题 $(".block li").hover( function(){ $(this).animate({backgroundColor: "#000"}); }, function(){ $(this).animate({backgroundColor: "#fff"}); } ); Need to change #fff to no color. Animation should occur from #000 to transparent . Any solution? 回答1: Instead of changing background color, remove that attribute! The code is as simple as: $("li").hover( function(){ $(this).toggleClass('hover', 1000); }, function(){ $(this).toggleClass('hover', 2000); } ); Example: http://jsfiddle.net/rdWTE/ For it to

Slide a div from right to left using animate()

走远了吗. 提交于 2020-01-09 20:40:54
问题 I want a div '.whole' to animate (slide from right to left) jQuery $('#menu').click(function() { $('.whole').toggleClass('r2'); $('#slideMenu').toggle(); }); .r2 { right: 200px } I am not able to use the function animate() properly. 回答1: This should work: $('#menu').click(function(event) { event.preventDefault(); // because it is an anchor element $('.whole').animate({ right: '200px' }); $('#slideMenu').toggle(); }); But your position property should already be set in CSS or you might not get

Slide a div from right to left using animate()

拈花ヽ惹草 提交于 2020-01-09 20:40:16
问题 I want a div '.whole' to animate (slide from right to left) jQuery $('#menu').click(function() { $('.whole').toggleClass('r2'); $('#slideMenu').toggle(); }); .r2 { right: 200px } I am not able to use the function animate() properly. 回答1: This should work: $('#menu').click(function(event) { event.preventDefault(); // because it is an anchor element $('.whole').animate({ right: '200px' }); $('#slideMenu').toggle(); }); But your position property should already be set in CSS or you might not get

Animate a Canvas circle to draw on load

丶灬走出姿态 提交于 2020-01-09 19:36:33
问题 OK Hello. I've decided to start using HTML canvas for a small project I have. There's no real start yet. I'm just learning the basics of Canvas and I want to Animate a circle <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>title</title> <style> body { margin: 0px; padding: 0px; background: #222; } </style> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <canvas id="myCanvas" width="578" height="250"></canvas> <script> var canvas = document.getElementById(

Animate a Canvas circle to draw on load

女生的网名这么多〃 提交于 2020-01-09 19:35:52
问题 OK Hello. I've decided to start using HTML canvas for a small project I have. There's no real start yet. I'm just learning the basics of Canvas and I want to Animate a circle <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>title</title> <style> body { margin: 0px; padding: 0px; background: #222; } </style> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <canvas id="myCanvas" width="578" height="250"></canvas> <script> var canvas = document.getElementById(

jQuery Pause / Resume animate

爷,独闯天下 提交于 2020-01-09 07:16:30
问题 This ain't working for me... $(document).ready(function(){ $('#h .a').animate({ top:'-=80px' },90,'linear'); $('#h .au,#h .di').animate({ left:'-=80px' },50000000,'linear'); $('#h .r').animate({ left:'-=80px' },250,'linear'); $("#h").animate('pause'); //pausing it at the start //resume pause switch $("#h").mouseover(function(){ $(this).animate('resume'); }).mouseout(function(){ $(this).animate('pause'); }); }); 回答1: Check out the demo here: http://api.jquery.com/clearQueue/ Looks like exactly

jQuery Add then remove width to consecutive elements in a loop

别等时光非礼了梦想. 提交于 2020-01-07 08:26:18
问题 OK so once a page has finished loading, I want to add a width to a group of elements, one after the other in a loop. Example: <div id="container-wrap"> <div id="container"></div> <div id="container"></div> <div id="container"></div> <div id="container"></div> <div id="container"></div> </div> So it would add the width to the first element, then remove then move on to the second element, so on and so forth. Then once it gets to the last one, it starts over. How would I do that? 回答1: Edited :