Here is a code snippet that removes the focus from a select element after it is clicked:
const select = document.querySelector('select');
select.addEventListener('focus', () => {
select.blur();
});
<select>
<option>Option 1</option>
<option>Option 2</option>
</select>
Is it feasible to modify this code so that there is no need to assign a constant/variable first?
Something similar to this:
// pseudocode
document.querySelector('select').addEventListener('focus', () => {
EventTarget.blur();
});
(And of course, I don't mean
document.querySelector('select').addEventListener('focus', () => {
document.querySelector('select').blur();
});
)