jQuery fadeToggle() compare fadeToggle speed

Description

jQuery fadeToggle() compare fadeToggle speed

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of jQuery Fade-Toggle Effect with Different Speeds</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
    p{//ww  w. j  a v a  2s . co m
        padding: 15px;
        background: #DDA0DD;
    }
</style>
<script>
$(document).ready(function(){
    // Fade Toggles paragraphs with different speeds
    $(".toggle-btn").click(function(){
        $("p.normal").fadeToggle();
        $("p.fast").fadeToggle("fast");
        $("p.slow").fadeToggle("slow");
        $("p.very-fast").fadeToggle(50);
        $("p.very-slow").fadeToggle(2000);
    });
});
</script>
</head>
<body>
    <button type="button" class="toggle-btn">Fade Toggle Paragraphs</button>
    <p class="very-fast">This paragraph will fade in/out with very fast speed.</p>
    <p class="normal">This paragraph will fade in/out with default speed.</p>
    <p class="fast">This paragraph will fade in/out with fast speed.</p>
    <p class="slow">This paragraph will fade in/out with slow speed.</p>
    <p class="very-slow">This paragraph will fade in/out with very slow speed.</p>
</body>
</html>



PreviousNext

Related