Js loads the read content and shows and hides the div example

  • 2020-03-30 01:42:12
  • OfStack

 
<head> 
<script> 
function check(){ 

var num = document.getElementById("choose").value; 
alert(num); 
if(num=="4"){ 
document.getElementById("show").style.display="block"; 
}else{ 
document.getElementById("show").style.display="none"; 
} 
} 
</script> 
</head> 
<body onload="check()"> 


<select id="choose" onchange="check()"> 
<option value="1"> The first </option> 
<option value="2"> The second </option> 
<option value="3"> The third </option> 
<option value="4"> The fourth </option> 
</select> 


<div id="show" style="display:none;"> 
<table> 
<tr> 
<td> Where there is a will, there is a way </td> 
<td> God pays those who help themselves </td> 
</tr> 
</table> 
</div> 
</body> 

Related articles: