javascript - Wordpress post slideToggle with each() issue -
i feel i've been trying work, problem i'm not familiar javascript nor jquery. guess it's simple adding 1 line, because i've got work.
i have wordpress blog loops out numerous of posts, i've added unique id's of them, i'm able grab problem doesn't work slidetoggle show content.
<script type="text/javascript">//<![cdata[ $(window).load(function(){ $(document).ready(function() { $(".togglecontainer").hide(); $('.show_hide').click(function() { event.preventdefault(); var pid = $(this).data('id'); var cid = $(this).data('container'); $(pid).add(cid).each(function() { $(cid).slidetoggle(1000); }); }); }); });//]]> </script>
then there's container:
<div class="togglecontainer" data-container="<?php the_id(); ?>"> <?php do_action( 'woocommerce_before_single_product_summary' ); ?> </div>
and toggle:
<a href="<?php the_permalink(); ?>" class="show_hide" data-id="<?php the_id(); ?>">
if use alert on each of them shows correct id, doesn't work when want toggle content.
try: $('[data-container*='+cid+']').slidetoggle(1000);
Comments
Post a Comment