代码示例:(标识:jsck_style_display_3)
<!DOCTYPE html>
<html>
<body>

<p>请在下面的列表中选择一种显示类型以更改 <span id="mySpan" style="color:blue;">此 span 元素的</span> 显示类型。</p>

<select onchange="myFunction(this);" size="3">
  <option>block
  <option>inline
  <option>none
</select>

<script>
function myFunction(x) {
  var whichSelected = x.selectedIndex;
  var sel = x.options[whichSelected].text;
  var elem = document.getElementById("mySpan");
  elem.style.display = sel;
}
</script>

</body>
</html>
运行结果: