Jquery not work but work after refresh -


i have jquery issue on page. click function not work when go on web page when refresh page click function working fine.

<script>     jquery(document).ready(function($){              jquery("#cart-var<?php echo $id; ?>").click(function(e){             alert('hiii');         });     });     });  // <--- } , ) here! </script> 

thanks, vivek

your code should this:

<?php if(!empty($id)): ?> <script> jquery(document).ready(function($){          jquery("#cart-var<?php echo $id; ?>").click(function(e){         alert('hiii');     }); }); </script> <?php endif; ?> 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -