Unresolved variable checked
Hi,
I am using this code:
document.getElementById('member').addEventListener('change', (event) => {
if (event.target.checked) {
console.log('Hello');
}
});
but Intellij gives me the warning:
Unresolved variable checked
Why do I get this warning? My code works fine and I get the console log.
Please sign in to leave a comment.
The IDE has no idea what your target element is, and
EventTarget
interface doesn't have checked property. You need to explicitly tell the IDE the type of the HTMLElement which is your target. For example, in Typescript this would be:And how would you do it with JavaScript?