Div + CSS + JS Multiple display/hide content Blocks

Source: Internet
Author: User
Related styles: Code
. Mainbox h3 { Margin-bottom : 0px ; Line-height : 32px ; Height : 32px ; Padding-left : 1em ; Background : URL (http://www.cnblogs.com/Images/forumbg.gif) Repeat-x 0 0 ; Font-size : 13px ; Font-weight : 700 ; Border-bottom : 1px solid # e6e7e1 ; Border-top : 4px solid # e8f0f7 ; Border-left : 1px solid # e8f0f7 ; Border-Right : 1px solid # e8f0f7 ; }
. Mainbox { Width : 880px ; Position : Relative ; Margin-left : Auto ; Margin-Right : Auto ; Margin-bottom : 5px ; }
. Headactions { Position : Absolute ; Top : 12px ; Right : 24px ; Line-height : 1em ; }
. Tablelist { Width : 880px ; Margin-left : Auto ; Margin-Right : Auto ; Border : 1px solid ; }
TD { Background : # E5f1f4 ; }

HTML: < Div Class = "Mainbox" >
< Span Class = "Headactions" >
< IMG ID = "Category_cn_img" SRC = "Http://www.cnblogs.com/Images/expand.jpg" ALT = "Expand/collapse" Onclick = "Toggle_collapse ('category _ cn ');" />
</ Span >
< H3 Onclick = "Toggle_collapse ('category _ cn ');" >
< A Href = "#" > Content </ A >
</ H3 >
< Div ID = "Category_cn" Style = "Display: none ;" >
< Table Class = "Tablelist" Align = "Center" Cellpadding = "0" >
< Tr >
< TD >
Title:
</ TD >
< TD Colspan = "3" >
< Te: tetextbox ID = "Txtcstitle" Runat = "Server" Width = "Pixel PX" Maxlength = "100" > </ Te: tetextbox >
</ TD >
</ Tr >
< Tr >
< TD >
Content:
</ TD >
< TD Colspan = "3" >
< Fckeditorv2: FCKeditor ID = "Txtcscontent" Runat = "Server" Height = "350px" Width = "98%" >
</ Fckeditorv2: FCKeditor >
</ TD >
</ Tr >
</ Table >
</ Div >
</ Div >

JS:Code
// Show or hide content
Function Toggle_collapse (objname ){
VaR OBJ = $ ( " # "   + Objname );
If (OBJ ){
OBJ. slidetoggle ( " 2000 " );
}
VaR IMG = $ ( " # "   + Objname +   ' _ Img ' );
If (IMG ){
If (IMG. ATTR ( " SRC " ) =   " Http://www.cnblogs.com/Images/collapse.jpg " ){
IMG. ATTR ( " SRC " , " Http://www.cnblogs.com/Images/expand.jpg " );
IMG. ATTR ( " Title " , " Expand " );

}
Else {
IMG. ATTR ( " SRC " , " Http://www.cnblogs.com/Images/collapse.jpg " );
IMG. ATTR ( " Title " , " Collapse " );
IMG. ATTR ( " Title " , " Collapse " );

}
}

}

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.