Use javascript to hide/display the specified area with the HTML element [legend]

Source: Internet
Author: User
Tags html sample

Javascript code:
Code
Copy codeThe Code is as follows:
Function expandOther (el, el2 ){
WhichEl = document. getElementById (el)
Button = document. getElementById (el2)
If (whichEl. style. display = 'None '){
WhichEl. style. display = '';
Button. value = "hidden ";
}
Else {
WhichEl. style. display = 'none ';
Button. value = "alarm ";
}

ExpandOther (e1, el2 ),
The e1 parameter can specify the event object to be operated, for example, an Input button with the ID of inputshowData,
The el2 parameter can specify a region to be hidden, such as TABLE and div.
<Input name = "inputshowData" id = "inputshowData" value = "" type = "button" onclick = "expandOther ('datadiv ', 'inputshowdata')"/>
Id: datadiv data display Layer
The id is inputshowData.
HTML sample CODE:
Copy codeThe Code is as follows:
<Fieldset>
<Legend>
<Input name = "inputshowData" id = "inputshowData" value = "" type = "button" onclick = "expandOther ('datadiv ', 'inputshowdata ') "/> </legend>
<Div id = "datadiv" style = "width: 400PX; height: 100px; overflow: auto;">
<Asp: GridView ID = "GridView1" runat = "server" CellPadding = "4" ForeColor = "#333333" GridLines = "None">
<RowStyle BackColor = "# F7F6F3" ForeColor = "#333333"/>
<FooterStyle BackColor = "# 5D7B9D" Font-Bold = "True" ForeColor = "White"/>
<PagerStyle BackColor = "#284775" ForeColor = "White" HorizontalAlign = "Center"/>
<SelectedRowStyle BackColor = "# E2DED6" Font-Bold = "True" ForeColor = "#333333"/>
<HeaderStyle BackColor = "# 5D7B9D" Font-Bold = "True" ForeColor = "White"/>
<EditRowStyle BackColor = "#999999" type = "regxph" text = "yourobjectname"/>
<AlternatingRowStyle BackColor = "White" ForeColor = "#284775"/>
</Asp: GridView>
</Div>
</Fieldset>

Is it easy to find?
I personally think.
However, this layer has a scroll bar, mainly based on the style Attribute overflow: auto; and has a specified width and height.
If the width is not directly specified, the scroll bar is displayed based on the browser width,
If the height is not specified, the scroll bar is not displayed. I am not good at art artists. The privilege is recorded here today. You can look back and see how you understood and wrote the code at that time.

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.