A strange theme sounds, but did not know what to call the correct theme. Depending on the conditions on the main page there is a display of either 1 block of elements or 2.

<?php if(isset($_SESSION['login'])): ?> <p>Привет</p> <? else: ?> <form action="1.php" method="post"> <? endif; ?> 

I have handlers that I post on the window.onload event on the elements that are generated in each condition. It turns out that in 1 case there is an error in attaching a handler that does not exist, since the cycle is <? else:?> did not work, and vice versa. How better to do?

  • one
    Check whether the object exists before working with it. - lampa
  • Option, ATP. - koza4ok
  • Thank you. Reconstruct in response. Close ... - koza4ok

1 answer 1

If without jQuery , look at how $.on() is done in jQuery and do the same. With jQuery , use $.on()