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
Post a Comment