I'm trying to open the dropdown menu using Javascript. The "Ask For More Time" button is supposed to open the dropdown menu by using focus()
and select()
javascript code but it's not working for the dropdown menu. What JS code do you use to open the dropdown menu?
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js"></script>
<form>
<input list="Ask" name="Ask">
<datalist id="Ask" class="dropdown-menu dropdown-menu-right">
<option value="One More Minute">
<option value="Send Request">
<option value="Enter Screen Time Passcode">
<option value="Cancel">
</datalist>
<button type="submit" id="submit">Send</button>
<input type="hidden" name="_next" value="https://classroom.google.com/u/0/h">
</form>
<button onclick=oncl() class="button button5">Ask For More Time</button>
</div>
</body>
</html>
Javascript:
function oncl() {
const datalist = document.getElementById('Ask');
datalist.focus();
datalist.select();
}