Hello, please tell me there is such a script

<script> // noty $(document).ready(function(){ $('#c-fr-prcount').click(function(){ $.ajax({ url: "friends/notyfrnds.php?id=<?=$myrow2[id]?>", cache: false, beforeSend: function() { $('#reqfrndscon').html(''); }, success: function(html){ $("#reqfrndscon").html(html); } }); return false; }); }); </script> ΠŸΡ€ΠΈ ΠΊΠ»ΠΈΠΊΠ΅ ΠΈΠ΄Π΅Ρ‚ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ° ΠΊΠΎΠ½Ρ‚Π΅Π½Ρ‚Π°, ΠΊΠ°ΠΊ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ ΠΏΡ€ΠΈ ΠΏΠΎΠ²Ρ‚ΠΎΡ€Π½ΠΎΠΌ ΠΊΠ»ΠΈΠΊΠ΅ закрывался Π±Π»ΠΎΠΊ?ΠŸΠΎΠΌΠΎΠ³ΠΈΡ‚Π΅ поТалуйста. 
  • What unit are we talking about? Could you give us an example of the html-code with which this code works? - vanchester
  • @vanchester here the script sent here the block itself <div id = "reqfrndscon"> </ div>. When you click on a link, applications for adding friend messages are loaded into this block. I need this window to be closed when you click on the link again. - andreykartavtsev

1 answer 1

 <script> window.onload = function (){ document.getElementById("c-fr-prcount").IsDown = false; document.getElementById("c-fr-prcount").onclick = function (){ if(!this.IsDown){ // Π”Π΅Π»Π°Π΅ΠΌ ajax запрос } else { // Π‘ΠΊΡ€Ρ‹Π²Π°Π΅ΠΌ Π±Π»ΠΎΠΊ } this.IsDown = !this.IsDown; } } </script> 

I'm not on friendly terms with jQuery, here’s a simple example on pure js