Home >Web Front-end >JS Tutorial >How to show hidden div in javascript
Javascript method to show hidden div: Create a showhidediv method, call it directly with the ID attribute, the code is [var sbtitle=document.getElementById(id)].
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
Javascript method to show hidden div:
1. Create a showhidediv method and call it directly with the ID attribute;
<script language="javascript"> function showhidediv(id){ var sbtitle=document.getElementById(id); if(sbtitle){ if(sbtitle.style.display=='block'){ sbtitle.style.display='none'; }else{ sbtitle.style.display='block'; } } } </script>
2. HTML page Structure
<a onMouseMove='showhidediv("baip")';> 点我 </a> <div id="baip"style="display:none;">隐藏显示的DIV</div>
Related free learning recommendations: javascript video tutorial
The above is the detailed content of How to show hidden div in javascript. For more information, please follow other related articles on the PHP Chinese website!