jquery exercises

jQuery Effect: Run an animation with less frames

jQuery Effect : Exercise-11 with Solution

Run an animation with less frames.
Sample Data :

HTML code:

<p><input type="button" value="Run"></p>


HTML Code :

<!DOCTYPE html>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  div {
    width: 150px;
    margin: 5px;
    float: left;
    background: #254BF4;
  <meta charset="utf-8">
  <title>Run an animation with less frames</title>
<p><input type="button" value="Run"></p>

JavaScript Code :

jQuery.fx.interval = 200;
$( "input" ).click(function() {
  $( "div" ).toggle(3000);

Note :
In jQuery toggle( [duration ] [, complete ] ) method is used to display or hide the matched elements. It has the following parameters :

  • duration : A string or number determining how long the animation will run. [Type- Number or String]
  • complete : A function to call once the animation is complete. [Type: Function()]

Live Demo:

See the Pen jquery-effect-exercise-11 by w3resource (@w3resource) on CodePen.

Contribute your code and comments through Disqus.

Previous: Animates all shown paragraphs to hide slowly (complete the animation within specified time).
Next: Toggle animation on and off.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming