Latest web development tutorials

HTML DOM Select size property

Select Object Reference Select Objects

Definition and Usage

size property sets or returns the drop-down list a number of display options.

grammar

Set size properties:

selectObject.size=integer

Returns size properties:

selectObject.size


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute size


Examples

Examples

Changing the number of visible down the list of options:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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()">修改大小</button>

</body>
</html>

try it"


Select Object Reference Select Objects