Select size Property - Return the number of visible options in a drop-down list: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Select

Description

Select size Property - Return the number of visible options in a drop-down list:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<select id="mySelect" size="1">
  <option>Cat</option>
  <option>Dog</option>
  <option>Horse</option>
  <option>A</option>
  <option>B</option>
  <option>C</option>
  <option>D</option>
</select>// w  w  w.  j a  v a2  s . co  m

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
     document.getElementById("mySelect").size = "4";
}
</script>

</body>
</html>

Related Tutorials