Tell me how to do this with the help of jQuery: there is an input text , it is necessary that when you click on it, a button and other form elements appear below it. When you click on the empty field, the form is again folded and only input text shown. This is used when posting on Vkontakte wall and similar social networks. Please throw some tutorial on this topic or an example. Thank you in advance!

  • 2
    YOU have more than half of not accepted answers - zloctb

1 answer 1

Well, I think how to show the form is clear. We hang the handler on focus or click and display the necessary elements:

 $('#id_поля').focus(function () { $('#блок_который_нужно_показать').show(); } 

It is necessary to hide it if the click occurred OUTSIDE the area of ​​the block that we show. I found the solution here :

 $(document).mouseup(function (e) { var container = $("YOUR CONTAINER SELECTOR"); if (container.has( === 0){ container.hide(); } }); 

which means the following - if the click was on an area that is NOT or is not our block, then hide the block.

  • and the usual $ ('# field_id'). blur (should work if you click not on the input path - AlekseyB
  • one
    Well, yes, but how to use the form that was shown using focus ? - Specter