javascript - Script issue in PHP -


<?php   echo "<script type='text/javascript'>$('#tnxerror_captcha').html('test');</script>"; ?> <div class="tnxerror" id="tnxerror_captcha"></div> 

the above code not working.

try this:
trying access tnxerror_captcha' before available in dom

<?php           echo "<script type='text/javascript'>$(function(){$('#tnxerror_captcha').html('test');});</script>";       ?>  

a better way embed javascript rahter echo since there noy dynamic html generation need:

<?php if(some_condition){?>     <script type='text/javascript'>      $(function(){       $('#tnxerror_captcha').html('test');     });     </script> <?php } ?> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -