본문 바로가기

JavaScript

[Script] display 옵션의 'none' 과 'inline' 과 'block'의 차이점


Display 옵션 : Inline (Text 박스가 옆으로 보여진다 )



Display 옵션 : block (Text 박스가 아래로 보여진다)



Display 옵션 : none (Text 박스가 보여지지 않는다)




################# Source #################


<html>
<head>
<title> display 옵션의 'none' 과 'inline' 과 'block'의  차이점 </title>
<script language="JavaScript">
<!--
 window.onload = function() {
  document.getElementById("div_description").style.display = "none";
 }

 // Reason 이 변경되면 넣는다.
 function changeCode1() {
  var descCode = document.getElementById("descCode");
  var description = document.getElementById("description");
  if(descCode.value == "99") {
   document.getElementById("div_description").style.display = "inline";
   description.value = "";
  } else if(descCode.value == "00"){
   document.getElementById("div_description").style.display = "block";
   description.value = "";
  } else {
   description.value = descCode.options[descCode.selectedIndex].text;
   document.getElementById("div_description").style.display = "none";
  }
 }
//-->
</script>
</head>

<body>

<table  border="0" cellspacing="1" cellpadding="3" style="width:97%">
<col width="10%" />
<col />
<tr>
 <td colspan="2">
  <P CLASS="para" ID="number1">
   <b>display 옵션의 'none' 과 'inline' 과 'block'의  차이점 확인</b><br>
   <b>div / span 에 상관없이 적용된다.</b>
  </P>
 </td>
</tr>
<tr>
 <td>Reason</td>
 <td>
  <select name="descCode" style="width:10%" OnChange="changeCode1()">
   <option value="">-- 선택 --</option>
   <option value="00">block</option>
   <option value="99">inline</option>
  </select>
  <div id="div_description">
   <input type="text" name="description" label="Description"
     style="width:65%" maxlength="1000" />
  </div>
 </td>
</tr>
</table>
</body>
</html>