The essence of the problem: the user profile should be able to post on the wall. It is necessary that there was an input form - an input field, an "Attach" button and the "Submit" button. But with one caveat, if the input field is out of focus, they should be hidden. I implemented it using onfocus.
text.onfocus = function() { $("#success").fadeIn(1); }; text.onblur = function() { $("#success").fadeOut(1); }; #success { display: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form-post"> <form> <textarea name="text" id="text" class="login-forma" placeholder="Что у Вас нового?" rows="1"></textarea> <div class="addpost" id="success"> <a href="">Прикрепить</a> <input type="submit" value="Рассказать" name="add_post" class="btn btn-success" /> </div> </form> </div> The problem is that if you press the attach button, or send, then, obviously, the text field loses focus and the click does not work, but simply hides the buttons. How to make them disappear only with the loss of focus of the field + loss of focus of the block itself with the buttons?