jQuery sliding effect

【Foreword】

        Today, the students asked the question that I said before, and the secondary menu slides down. Just tell him jQuery's slide class method control, the following summarizes

        The secondary drop-down menu is actually very simple as long as you understand the principle.

        Knowledge Point: > Child Selector

        Share the next steps: http://www.cnblogs.com/jianxian/p/8685593.html

 

【Case】

//Dynamic in and out
        $('.nav_ul>li').hover(function() {
            $(this).find('ul').slideDown(200);
        }, function() {
            $(this).find('ul').slideUp(100);
        });

 

 

【List】

(1) Slipping

(2) Slide up

(3) Switch up and down

 

【Details】

(1) Slipping

$(selector).slideDown(speed,callback);

  The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast" or milliseconds.

  The optional callback parameter is the name of the function to execute after the swipe is complete.

<script src="/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".flip").click(function(){
    $(".panel").slideDown("slow");
  });
});
</script>
<style type="text/css">
div.panel,p.flip{
margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
}
div.panel{
height:120px;
display:none;
}
</style>
<div class="panel">
<p>W3School - The Leading Web Technology Tutorial Site</p>
<p>At W3School, you can find all the website building tutorials you need. </p>
</div>
<p class="flip">Click here</p>

 

(2) Slide up

$(selector).slideUp(speed,callback);

 

(3) Switch

The jQuery slideToggle() method toggles between the slideDown() and slideUp() methods.

If elements slide down, slideToggle() slides them up.

If elements slide up, slideToggle() slides them down.

<script src="/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".flip").click(function(){
    $(".panel").slideToggle("slow");
  });
});
</script>
<style type="text/css">
div.panel,p.flip{
margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
}
div.panel{
height:120px;
display:none;
}
</style>
<div class="panel">
<p>W3School - The Leading Web Technology Tutorial Site</p>
<p>At W3School, you can find all the website building tutorials you need. </p>
</div>
<p class="flip">Click here</p>

 

 

 

 

 

 

.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326122748&siteId=291194637