I'm looking for a DOM event that I can listen to with JavaScript for when a select element that has been opened (but no options changed) is then closed by clicking off the select element, somewhere (anywhere) else on the page.
It's not the blur
event of the select, because the select retains focus. Likewise, it's not the focus
event of some other element or the document, or a mousedown
or click
on the window, document or body.
It's not the change
event of the select, since no option within the select has been changed.
I'm not concerned about legacy Internet Explorers - just something to work in standards compliant modern browsers. Proprietary hacks could be worth knowing though.
I've created a JSFiddle to demonstrate the problem: http://jsfiddle.net/premasagar/FpfnM/
- Click on the selectbox in the "Result" panel
- Click on the text marked "HERE" (or anywhere else) with a single click and see if any event is added to the log. There isn't an event in the latest Chrome or Firefox.
So the question is: What JavaScript could be added, to get an event logged when clicking off the selectbox?
(I've asked a similar, but different question here:
JavaScript on iOS: opening an HTML select element)