php - use dynamic div on animated collapse -
i'm using animated collapse js library here: http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm
and i'm trying use dynamic div's it's not toggling. ideas?
<head> <script type="text/javascript" src="includes/js/animatedcollapse.js"></script> </head> <body> <?php ($i = 1; $i <= 5; $i++) { ?> <script type="text/javascript"> animatedcollapse.adddiv('location-<?php echo $i; ?>', 'fade=1') </script> <div id="location-<?php echo $i; ?>"> <a href="javascript:animatedcollapse.hide('location-<?php echo $i;?>')">close</a> test </div> <a href="javascript:animatedcollapse.toggle('location-<?php echo $i;?>')">toggle</a> <?php } ?> <script type="text/javascript"> animatedcollapse.ontoggle=function($, divobj, state){} animatedcollapse.init() </script>
i may wrong, doesn't seem necessary use php create incrementing variable.
you write same loop in javascript, inside script tags: think using jquery's slidetoggle might make easier you... maybe along these lines:
for (var = 1, <= 5, i++ ){ $(document).ready(function(){ $('divtobetoggled' + i).click(function(){ $('divtoberevealed' + i).slidetoggle('slow'); }); }); }
Comments
Post a Comment