I am struggling to pass an argument to a function during a JavaScript event.
When the drop-down menu is focused, the text changes based on the argument passed to the function call.
I can't seem to get this functionality to work! Any assistance would be greatly appreciated.
function adjustText(value) {
if (value) {
document.querySelector('.focused').textContent = 'Focused';
} else {
document.querySelector('.focused').textContent = 'LOST';
}
}
document.querySelector('.selector').onfocus = function() { adjustText(true); };
document.querySelector('.selector').onblur = function() { adjustText(false); };
<select class='selector'>
<option value='one'>One</option>
<option value='two'>Two</option>
</select>
<br/>
<br/>
<br/>
<div class='focused'>XXX</div>