JavaScript hide/Show specified area with HTML element "Legend" Usage _javascript tips

Source: Internet
Author: User
Tags html sample
JavaScript code:
Code
Copy Code code 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 = "Display";
}

Expandother (E1,el2),
The e1 parameter can specify the event object that needs to be manipulated, such as an input button with an ID of inputshowdata.
The EL2 parameter can specify an area that needs to be hidden, such as Table,div.
<input name= "Inputshowdata" id= "Inputshowdata" value= "type=" button "onclick=" Expandother (' datadiv ', ' Inputshowdata ') "/>
ID is datadiv data display layer Area
ID is inputshowdata action button
HTML Sample code:
Copy Code code 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"/>
<editrowstyle backcolor= "#999999"/>
<alternatingrowstyle backcolor= "White" forecolor= "#284775"/>
</asp:GridView>
</div>
</fieldset>

Is it easy to find out?
Personally feel.
However, this layer has scroll bars, mainly based on the style attribute Overflow:auto, and has the specified width and height.
If you do not specify the width directly, the scroll bar is displayed as a standard for the browser width.
If you do not specify a height, the downward scroll bar is not displayed, as appears to be the case. I do not do the art. Today's right when recorded here, later you can look back at that time how you understand and write code.
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.