jquery Click Div Scalable Explicit Menu window code

Source: Internet
Author: User

The effect of the following figure, we did not do landscaping, you can download after the art to make their own desired effect.

First we define some CSS

The code is as follows Copy Code
<style type= "Text/css" >
p{margin:0;padding:0;}
. Cc{width:200px;height:200px;float:left;background: #dedede;}
P{width:200px;height:20px;text-align:center;background: #CCC; float:left;}
#box {overflow:hidden;width:410px;}
</style>

Referring to the jquery file, simply wrote a few lines of telescopic code as follows

  code is as follows copy code
<script src = "Jquery-1.7.2.min.js" type= "Text/javascript" ></SCRIPT>
<script type= "Text/javascript"
$ ( function () {
 $ (". CC"). Animate ({"height": "0"})
 $ ("#box P"). Click (function () {
  var ind=$ (". P"). index (this);
  $ (". CC"). Animate ({"height": "0"}). EQ (Ind). Animate ({"Height": "200px"});
 })
})
</script>
<body>

Here we have the. CC ($ (". CC") defined in CSS. Animate ({"height": "0"}) file must have the same name as jquery, and Id=box is also used in jquery ($ ("#box p"). Click ( function () {) to modify the ID and style name at the same time you need to modify the places I listed.
<!--Add the following code to <body> and </body>;

The code is as follows Copy Code
<div id= "box" >
<div style= "Float:left; width:200px; " >
<p class= "P" > click 1 show what </p>
<div id= "box_1" class= "CC" >1</div>
</div>
<div style= "float:left;width:200px;" >
<p class= "P" > click 2 Show What </p>
<div id= "Box_2" class= "CC" >2</div>
</div>
</div>

So we can easily and quickly implement DIV display hidden effect oh.

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.