Copy codeThe Code is as follows: <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Script src = "http://demo.jb51.net/jslib/jquery/jquery.js" type = "text/javascript"> </script>
<Style>
<! --
Body {
Margin: 10px auto;
Width: 570px;
Font: 75%/120% Arial, Helvetica, sans-serif;
}
. Accordion {
Width: 480px;
Border-bottom: solid 1px # c4c4c4;
}
. Accordion h3 {
Background: # e9e7e7 url (images/arrow-square.gif) no-repeat right-51px;
Padding: 7px 15px;
Margin: 0;
Font: bold 120%/100% Arial, Helvetica, sans-serif;
Border: solid 1px # c4c4c4;
Border-bottom: none;
Cursor: pointer;
}
. Accordion h3: hover {
Background-color: # e3e2e2;
}
. Accordion h3.active {
Background-position: right 5px;
}
. Accordion p {
Background: # f7f7f7;
Margin: 0;
Padding: 10px 15px 20px;
Border-left: solid 1px # c4c4c4;
Border-right: solid 1px # c4c4c4;
}
--> </Style>
<Script type = "text/javascript"> </script>
<Div class = "accordion">
<H3> Question One Sample Text <P style = "display: none;"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa
Diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula. </p>
<H3> This is Question Two <P style = "display: none;"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa
Diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula. </p>
<H3> Another Questio here <P style = "display: none;"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa
Diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula. </p>
<H3 class = "active"> Sample heading <P style = "display: block;"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa
Diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula. </p>
<H3> Sample Question Heading <P style = "display: none;"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi malesuada, ante at feugiat tincidunt, enim massa gravida metus, commodo lacinia massa
Diam vel eros. Proin eget urna. Nunc fringilla neque vitae odio. Vivamus vitae ligula. </p>
</Div>
<Script type = "text/javascript"> // <! [CDATA [
$ (Function (){
/* $ ('. Accordion h3'). click (function (){
$ ('. Accordion p'). hide ();
$ (This). next (). show ();
});*/
Var Q = {
H3: $ ('. accordion h3 '),
P: $ ('. accordion p '),
Qiehuan: function (){
This. h3.click (function (){
Q. p. hide ();
$ (This). next (). show ();
});
}
};
Q. qiehuan ();
});
//]> </Script>