Hello DP I have hit a bit of a problem im working in wordpress inside a loop that reproduces the same code 10 times ( index.php ) on each wordpress post I have the code below which creates a toggled div. But when i click the toggle it works on every post rather then just the one... is there any way to avoid this? <button>Share this article</button> <div class="social">whqahadhdfh</div> HTML: Jquery <script> $("button").click(function () { $(".social").slideToggle("slow"); }); </script>
Okay, try this one : <script type="text/javascript"> <?php if(have_posts()) : while(have_posts()) : the_post(); ?> $("button#s<?php the_ID(); ?>").click(function () { $(".social<?php the_ID(); ?>").slideToggle("slow"); }); <?php endwhile; endif; ?> </script> <?php if(have_posts()) : while(have_posts()) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_content(''); ?> <button id="s<?php the_ID(); ?>">Share this article</button> <div class="social<?php the_ID(); ?>">whqahadhdfh</div> <?php endwhile; endif; ?> PHP: