When i try to fire a event listener in js for an input element it is not getting called. This is how I am trying to do it.
var el = document.getElementById(“inputEl”);
el. addEventListener('focus', (event) => {
console.log(‘inside this block’);
});
What am I doing wrong here?
Change your js as below:
var el = document.getElementById("inputEl");
el.addEventListener('focus', (event) => {
console.log('inside this block');
});
And also place your.js file at the bottom in your index.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.