Is it possible to know when the HTML <datalist> is currently active/open (via css pseudo-element or javascript event or otherwise)?
Knowing when datalist is currently active/open
45 Views Asked by Simon Ferndriger At
1
Is it possible to know when the HTML <datalist> is currently active/open (via css pseudo-element or javascript event or otherwise)?
You can use the
onfocusandonfocusoutevent handlers of the associated input tag.onfocusoutwill not fire of you select one of the datalist options because the input tag will still have focus. You can add theonchangeevent handler for this.This is not a perfect solution since it does not work when you select the same value twice.