Home >Web Front-end >JS Tutorial >How to show hidden div in javascript

How to show hidden div in javascript

coldplay.xixi
coldplay.xixiOriginal
2021-04-06 15:55:083454browse

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)].

How to show hidden div in javascript

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==&#39;block&#39;){
   sbtitle.style.display=&#39;none&#39;; 
   }else{
   sbtitle.style.display=&#39;block&#39;;
   }
}
}
</script>

2. HTML page Structure

<a onMouseMove=&#39;showhidediv("baip")&#39;;> 点我  </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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn