There is a jQuery handler that, when you click on the "hide" button, collapses certain elements:

$(document).ready(function() { ... $('.hide').click(function() { ... }) ... }); 

I need to make it so that when the user first logs on to the site, this piece was deployed as usual, and when logged in again, it is already minimized, I try to do this through the sessions:

 <?php session_start(); if(isset($_SESSION['name'])){ здесь надо выполнить действие кнопки "hide" } $_SESSION['name'] = "test"; ?> 

Tell me how this can be implemented? There are quite a few things in the handler of the button, can it be wrapped somehow in a function and called from php?

  • I also asked myself this question but did not get an answer, + you and I look forward to hearing with you - user33274
  • if at the session level you can replace it with localStorage - Vfvtnjd
  • toster.ru/q/326025 here is your question on toster, we are watching together - user33274
  • otvet.mail.ru/question/191055574 here also on mail.ru - user33274

2 answers 2

 <?php session_start(); if(isset($_SESSION['first_in'])){ ?> <script src="libs/jquery/jquery-1.11.1.min.js"></script> <script src="common.js"></script> <script type='text/javascript'> $(document).ready(function() { $('.hide').trigger('click'); }); </script> <?php } $_SESSION['first_in'] = "first_in_ok"; ?> 

Understood)

     if(isset($_SESSION['perviy_vhod'])){ echo '<script> $(function(){ $('.hide').trigger('click'); }); </script>'; $_SESSION['perviy_vhod'] = 'perviy_vhod_vipolnen'; } 

    source https://toster.ru/q/326025

    • Error: Uncaught ReferenceError: $ is not defined - teckor32
    • it turns out that you have not done something with $, that is, this perviy_vhod - user33274
    • no, he swears that $ is not declared, which before (function ()), tried to prescribe jQuery there, starts to swear at jQuery - teckor32
    • look at the source, I duplicated your question there, and on Mile, but there is silence, on a toaster - I told you that I asked this question - user33274
    • not defined this is not declared - respectively, you specified the variable but did not describe it, but there is no need to specify js - js is called - user33274