simple test for toggle div bar

1593 단어 html브라우저
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>toggle div</title>

<script language="JavaScript" type="text/javascript">

window.onload = init;
function init()
{
      document.getElementById('dropper1').style.display = 'block';
      document.getElementById('dropper2').style.display = 'none';
     
}
function toggleDiv(element)
{
   var otherId = element == "dropper1" ? "dropper2" : "dropper1";
    	document.getElementById(otherId).style.display = 'none';
      document.getElementById(element).style.display = 'block';
      
   }
</script>

</head>
<body>
	<table>
		<tr>
			<td onClick="toggleDiv('dropper1');">1</td>
			<td onClick="toggleDiv('dropper2');">2</td>
		</tr>
	</table>
      

      <div id="dropper1">
            <ul>
                 <li>1</li>
                
            </ul>
      </div>
       <div id="dropper2">
            <ul>
                
                 <li>2</li>
            </ul>
      </div>
</body>
</html>

좋은 웹페이지 즐겨찾기