Handle the mousedown-event instead of the click-event.
The mousedown event will be handled before the focus of another element is lost.
In your mousedown eventhandler, you need to to prevent event default behavior.
e.preventDefault(); // in your mousedown eventhandler
JS-Fiddle demo