I want to change a jquery command via PHP.
So for example:
$envelope<?php echo'1'?>.toggleClass( 'card-out' );
is this valid to use? I tried it and i think it didn't work, but i don't know if the mistake is in that line or in the rest of the code.
this is the main part of my code:
<div class="library-card envelope<?php echo'2'?>">
<div class="front">
<p class="stamp">Jacob Haase<br> 18.05.2000</p>
</div>
<div class="card">sdsdsd</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
var $envelope = $( '.library-card.envelope' ),
$card = $envelope.find( '.card' ),
$front = $envelope.find( '.front' );
$front.on( 'click', function( event ) {
$envelope<?php echo'2'?>.toggleClass( 'card-out' );
});
$card.on( 'click', function( event ) {
$envelope<?php echo'2'?>.toggleClass( 'card-out' );
});
</script>
</div>
thank you!
<?php echo '1' ?>is meaningful there. PHP and in-browser JS won't interfere if you know what you're doing. The question is: Should you do this?$. So, you know it's a jQuery object, and you can call jQuery methods on it