<html>
<body>
<form>
<select name="selectName" id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
</form>
<p>Click the button to return the value of the name attribute of the drop-down list.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
let x = document.getElementById("mySelect").name;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>