JQuery implements DIV layer contraction and expansion, and jquerydiv layer Expansion
This article describes how jQuery implements DIV layer contraction and expansion. Share it with you for your reference. The specific implementation method is as follows:
Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> jQuery achieves DIV layer contraction and expansion </title>
<Script type = "text/javascript" src = "/images/jquery. js"> </script>
<Style>
/* Scale down and expand */
. Text {line-height: 22px; padding: 0 6px; color: #666 ;}
. Box h1 {padding-left: 10px; height: 22px; line-height: 22px; background: # f1f1f1; font-weight: bold ;}
. Box {position: relative; border: 1px solid # e7e7e7 ;}
</Style>
</Head>
<Body>
<Script type = "text/javascript">
// Hide and expand
$ (Document). ready (function (){
$ (". Box h1"). toggle (function (){
$ (This). next (". text"). animate ({height: 'toggle ', opacity: 'toggle'}, "slow ");
}, Function (){
$ (This). next (". text"). animate ({height: 'toggle ', opacity: 'toggle'}, "slow ");
});
});
</Script>
<! -- Contract and expand effect -->
<Div class = "box">
<H1> contraction and expansion effect <Div class = "text">
1 <br/>
2 <br/>
3 <br/>
4 <br/>
5 <br/>
</Div>
</Div>
<Br/>
<Div class = "box">
<H1> contraction and expansion effect <Div class = "text">
1 <br/>
2 <br/>
</Div>
</Div>
<Br>
<Font color = red> refresh the page for the first running. </Font>
</Body>
</Html>
I hope this article will help you with jquery programming.