change from document.activeElement to $(document).getActiveElement()