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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -