Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 382
Satch3000 Avatar asked Mar 10 '26 13:03

Satch3000


1 Answers

Try this

<?php if (some condition): ?>
$('#myID').show();
<?php endif; ?>
like image 145
SenorAmor Avatar answered Mar 12 '26 02:03

SenorAmor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!