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.