Javascript to display and hide information

Source: Internet
Author: User

Javascript to display and hide information

Information Display and hiding are usually used in some cases, such as registration information. The following is a good example. If you are interested, you can understand it.

When writing the registration page, the required information is visible and optional information is hidden. If you want to enter the required information, click "details ".

The Code is as follows:

<! -- The following code uses javascript to display and hide information -->

<! DOCTYPE html>

<Html>

<Head>

<Meta charset = "UTF-8">

<Title> Insert title here </title>

<Script type = "text/javascript">

Function $ (idvalue ){

Return document. getElementById (idvalue );

}

Function showtext (){

If ($ ('text'). style. display = 'None '){

$ ('Text'). style. display = '';

} Else {

$ ('Text'). style. display = 'none ';

}

}

</Script>

</Head>

<Body>

<Div id = "text" style = "display: none;"> here is the hidden information </div>

<Button id = "morebtn" onclick = "showtext ();"> details </button>

</Body>

</Html>

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.