I have a table cell with text input #usernameInput and link #saveLink . Using jQuery I have a function assigned to the click event #saveLink .
What I'm trying to achieve when: #usernameInput loses focus, I want to hide it. If he does not lose focus on #saveLink . In other words, if the user clicks anywhere other than #saveLink , I want to hide #usernameInput , otherwise call the click event on #saveLink .
I have no problem handling $('#usernameInput').focusout() , but I can't get it to determine if the save link was clicked.
Here is what I still have.
<script type="text/javascript"> $('#usernameInput').focusout(function () { if (!$('#saveLink').is(':focus')) { $('#usernameInput').hide(); } return; });</script>
source share