Skip to content
Advertisement

PHP Conditions in Javascript code

I need to add a PHP condition inside some javascript code like this:

<script>
$(document).ready(function() {

<?php if (some condition) {
   $('#myID').show();
}

});
</script>

Is this possible?

Advertisement

Answer

Try this

<?php if (some condition): ?>
$('#myID').show();
<?php endif; ?>
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement