Select type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Select

Description

The type property returns the type of form drop-down list.

For a drop-down list this will be "select-one" or "select-multiple".

Return Value

A String, representing the type of form element the <select> element is

The following code shows how to return which type of form element a drop-down list is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form>
<select id="mySelect" multiple>
  <option>CSS</option>
  <option>HTML</option>
  <option>SQL</option>
  <option>Javascript</option>
</select>/*ww  w . j av a 2  s. co m*/
</form>

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

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySelect").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials