div 숨기기 표시

1561 단어 div
<html>
<script> 
function clik(){
	var div_data=document.getElementById("div_ta").getElementsByTagName("div");
	alert('111='+div_data.length);
	
	for(var i=0;i<div_data.length;i++)
	{
		if(div_data[i].style.display=="none")
		{
			div_data[i].style.display="block";
		} else {
			div_data[i].style.display="none";
		}
	}
}
</script>
<body>
	<input type="button" onClick="clik()" value="button"/>

 <table width="223" height="123" border="1" id="div_ta">
  <tr>
    <td><div id="div1" style="display:none;">div1</div></td>
    <td><div id="div2" style="display:block;">div2</div></td>
   
  </tr>
  <tr>
    <td><div id="div4" style="display:none;">div4</div></td>
    <td><div id="div5" style="display:block;">div5</div></td>
  </tr>
  <tr>
    <td><div id="div7" style="display:none;">div7</div></td>
    <td><div id="div8" style="display:block;">div8</div></td>
  </tr>
</table>

</body>

</html>

좋은 웹페이지 즐겨찾기