The effect of HTML design hiding and displaying

Source: Internet
Author: User

Hide and show

A lot of the time we need to hide something from the web, or the app (like PhoneGap using HTML5,JS to develop Android apps, iOS apps).

Here I have summed up several ways:

Note that the jquery package needs to be introduced here, and I'll give you a http://down.51cto.com/data/1357745. Remember to create a directory of jquery in the same directory as your Web page, and put the package in it.

1. Use the Hide () and show () method of jquery. The code below, you can copy to try.

        Hide (), use Show (), and, of course, select the element first.
<! DOCTYPE html>$ (document). Ready (function() {  $ ("#hide"). Click ( function () {  $ ("P"). Hide ();  });  $ ("#show"). Click (function() {  $ ("P"). Show ();  });}); </script>

2. Fade-in Fadein ()----effect: Slowly changing the CSS properties of an element to make it dynamic. This can also be done to hide, display the function.

JQuery FadeIn () method

JQuery fadeIn () is used to fade in hidden elements.

Grammar:
$ (selector). FadeIn (Speed,callback);

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

The optional callback parameter is the name of the function that is executed after fading completes.

<! DOCTYPE html>$ (document). Ready (function(){  $("button"). Click (function(){    $("#div1"). FadeIn (); $("#div2"). FadeIn ("slow")); $("#div3"). FadeIn (3000); });});</script>

3. Swipe to hide and show.

JQuery Slidetoggle () method.

JQuery has the following sliding methods:

    • Slidedown ()
    • Slideup ()
    • Slidetoggle ().

The JQuery Slidetoggle () method can be toggled between the Slidedown () and the Slideup () method.

If the elements slide down, slidetoggle () can slide them up.

If the elements slide up, slidetoggle () can slide them down.

$ (selector). Slidetoggle (Speed,callback);

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

The optional callback parameter is the name of the function that is executed after the slide is completed.

 <! DOCTYPE html> $ (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>

4. Use CSS styles: Display:none is implemented with the show () mode of jquery.

<! DOCTYPE html>$ (document). Ready (function() {  $ ("#show"). Click (  function() {  $ ("#hiddenDIV"). Show ();  });}); </script>

4.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.