View Full Version : Resolved Animated Collapsible DIV v2.01 travel repeatly?

01-13-2009, 03:33 AM
1) Script Title: Animated Collapsible DIV v2.01

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem:

currently i am using following for a single DIV

animatedcollapse.addDiv('x_item_enquiry', 'fade=1');

so i want to know how to handle with multiple DIV with variable DIV pattern ID

eg $('div[@id^=DIV_]').animatedcollapse.addDiv();

can i assign all DIV with ID pattern DIV_xxx ?

many thanks/Davis.

01-13-2009, 08:24 AM
There are several ways to do this. One would be to define an array of IDs corresponding to those of your collapsible DIVs, then loop through them to enable the script on them. For example:

var mydivs=['div1', 'anotherdiv', 'div3', 'catdiv']

for (var i=0; i<mydivs.length; i++){

01-13-2009, 03:53 PM

thanks for your quick reply.

as my DIV html are generated dynamic, ie

<div id="x_1"></div>
<div id="x_22"></div>
<div id="x_13"></div>

and i only know the pattern x_?? , so can you show me if possible using jquery travel method? like kinda this sytnax $('div[@id^=x_]').animatedcollapse.addDiv(); is it support? so i can assign all DIV id with x_ wildcard ?

many thanks.

01-13-2009, 07:15 PM
The script isn't actually a jQuery plugin, so you can't call addDiv() directly on a set of jQuery elements. However, that's easy to work around. Simply gather the elements you want to target using jQuery first, then loop through it and call animatedcollapse.addDiv() on each element. An example:

var $group=$('#jason, #kelly, #michael') //group of elements as a jQuery object
animatedcollapse.addDiv(this.id, 'fade=1,height=80px')

01-14-2009, 02:52 AM

THANKS very much for your help.

that is the way I am looking for..:) as i am not much familiar with jquery.
i want to "grep" a pattern of DIV id with x_div_ wildcard

ev_enquiry = $('div[@id^=x_div_]');
ev_enquiry.each( function(i) {
animatedcollapse.addDiv(this.i, 'fade=1');

can you tell how to pass the DIV id inside addDiv()? as this.i not work..:(


01-14-2009, 03:49 AM
previous problem are solved, so how can i change this post as solved status? thanks/Davis.

01-14-2009, 07:47 AM
You can go to your first post in this thread, click http://www.dynamicdrive.com/forums/images/buttons/edit.gif then click Go Advanced and add the Resolved prefix to the thread title.

Good luck!