I have this function displaySelectedUser, so I want to Set displaySelectedUser as a change event listener for the <select></select>
UI element using only the DOM Selector API.
this is the code that I have tried out:
<body>
<div class="select">
<select class="select-text">
<option disabled selected>Select User</option>
<option>user 1</option>
<option>user 2</option>
</select>
</div>
<body>
<script>
const displaySelectedUser = () => {
//some code...
};
document.querySelector('select').change = displaySelectedUser;
};
</script>