Select sizeProperty

Select 对象参考手册Select Object

Definition and Usage

The size property sets or returns the number of options displayed at once in a drop-down list.

Syntax

Set the size property:

selectObject.size=integer

Return the size property:

selectObject.size


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the size property


Example

Example

Change the number of visible options in the drop-down list:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(){
  document.getElementById("mySelect").size=4;
}
</script>
</head>
<body>

<form>
<select id="mySelect">
  <option>Apple</option>
  <option>Pear</option>
  <option>Banana</option>
  <option>Orange</option>
</select>
</form>
<button type="button" onclick="displayResult()">Change size</button>

</body>
</html>

Try it Yourself »


Select 对象参考手册Select Object Other Extensions