jQuery hide() compare hide speed

Description

jQuery hide() compare hide speed

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of jQuery Animated Show Hide Effects</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
    p{// w  ww  . jav  a  2  s  .  c  om
        padding: 15px;
        background: #F0E68C;
    }
</style>
<script>
$(document).ready(function(){
    // Hide displayed paragraphs with different speeds
    $(".hide-btn").click(function(){
        $("p.normal").hide();
        $("p.fast").hide("fast");
        $("p.slow").hide("slow");
        $("p.very-fast").hide(50);
        $("p.very-slow").hide(2000);
    });

    // Show hidden paragraphs with different speeds
    $(".show-btn").click(function(){
        $("p.normal").show();
        $("p.fast").show("fast");
        $("p.slow").show("slow");
        $("p.very-fast").show(50);
        $("p.very-slow").show(2000);
    });
});
</script>
</head>
<body>
    <button type="button" class="hide-btn">Hide Paragraphs</button>
    <button type="button" class="show-btn">Show Paragraphs</button>
    <p class="very-fast">This paragraph will show/hide with very fast speed.</p>
    <p class="normal">This paragraph will show/hide with default speed.</p>
    <p class="fast">This paragraph will show/hide with fast speed.</p>
    <p class="slow">This paragraph will show/hide with slow speed.</p>
    <p class="very-slow">This paragraph will show/hide with very slow speed.</p>
</body>
</html>



PreviousNext

Related