This article briefly introduces several methods for displaying and hiding Divs. This article summarizes several methods for displaying and hiding Divs, including style, CSS, and JQuery, for more information, see
Example
The Code is as follows:
$ ("# Top_notice" ).css ("display", "block"); // method 1st
// $ ("# Top_notice"). attr ("style", "display: block;"); // method 2nd
// $ ("# Top_notice"). show (); // method 3rd
1. Change the element to the class to hide p, provided that the hidden attribute is defined for the new class style.
The Code is as follows:
$ ("# SendPhoneNum"). attr ("class", "n_input3 ");
1.2 set the style attribute for the element
The Code is as follows:
$ ("# Top_notice"). attr ("style", "display: block ;");
2. Use jquery's css method to set p hiding
The Code is as follows:
$ ("# SendPhoneNum" ).css ("display", "none ");
3. Use the show () and hide () Methods of jquery to set p hiding.
The Code is as follows:
$ ("# TextDiv"). show (); // display p
$ ("# ImgDiv"). hide (); // hide p
P is often used to show and hide p in programming. The following describes several methods:
The Code is as follows:
Example
1. $ ("# demo"). attr ("style", "display: none;"); // hide p
$ ("# Demo"). attr ("style", "display: block;"); // display p
2. $ ("# demo" ).css ("display", "none"); // hide p
$ ("# Demo" ).css ("display", "block"); // display p
3. $ ("# demo"). hide (); // hide p
$ ("# Demo"). show (); // display p
4. $ ("# demo"). toggle (
Function (){
$ (This). attr ("style", "display: none;"); // hide p
},
Function (){
$ (This). attr ("style", "display: block;"); // display p
}
);
For your reference only!