Hide and display a JS processing button

Source: Internet
Author: User

The display attribute of the button in HTML controls the hide and display functions of the button. It is hidden when display = "NONE" and displayed when display = "Block; and display exists in the style. Set the display attribute in HTML as follows:Code:

 
<Div>
<Button id = "displaybtn" style = "background-color: #666666; display: block;"> display button </button>
<Button id = "hiddenbtn" style = "background-color: #666666; display: none;"> hidden button </button>
</Div>

After you know which property controls the hide and display of the button and the position of the property, it becomes easy to call and set the button in JS (pay attention to the hierarchical relationship ). The Code is as follows:

FunctionDisplayandhiddenbtn (btnid, type ){
VaRCurrentbtn = Document. getelementbyid (btnid );
If(Type = "D "){
Currentbtn. style. Display = "Block ";//Display attribute in style
}
Else If(Type = "H "){
Currentbtn. style. Display = "NONE ";
}
}

Here the parameter btnid identifies the button ID, and type indicates whether to set this button to hidden ("H") or display ("D") status.

There are many other attributes of the button, such as onmouseover, onmouseout, onclick, and other event registration functions, which are not described here.

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.