JavaScript controls HTML element display/Hide implementation code _javascript tips
Source: Internet
Author: User
1. Writing JS functions <script type= "Text/javascript" >
function display (y) {$ (Y). style.display= ($ (y). style.display== "None")? "": "None";
function $ (s) {return document.getElementById (s);}
</script>
2. HTML element to show/hide plus id attribute <table>
<tr id= "Menu" >
<td> control the show/hide of this TR </td>
</tr>
</table>
3, add buttons, links, etc trigger JS function <input type= "button" onclick= "Display (' Menu ')" value= "Show/Hide"/>
<a href= "#" onclick= "Display (' Menu ')" > Show/Hide </a>
JavaScript shows hidden layers <div id= "layer" style= "display:none;" > Advertising </div>
<input type= "Botton" onclick= "display (layer)" >
Two: JavaScript controls hidden display of page controls JavaScript controls the two ways that page controls hide the display, except that they are still occupied on the page after the control is hidden
method One: document.all["Panelsms"].style.visibility= "hidden";
document.all["panelsms"].style.visibility= "visible";
Method Two: document.all["Panelsms"].style.display= "none";
document.all["panelsms"].style.display= "inline";
Method hides the position of the page after it is occupied by the control just does not show
Method two hide the position of the page is not occupied
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