JQuery implements DIV layer contraction and expansion, and jquerydiv layer Expansion

Source: Internet
Author: User

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.

Related Article

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.