toggle on dynamically referenced DIVs

toggle on dynamically referenced DIVs

Hello,

I want to use a standard toggle function, as shown in the UI demo, but apply this to multiple elements on a page that have been given an ID dynamically in php.

For example with a single toggle I would have a link with id "button" which when clicked will run the JQuery to toggle a div with id "toggle-div".  This works fine.

But through php I will have multiples of these, with unique IDs as I append the record id from the database to the end, and I want the JQuery to work for each set, e.g.
"button-1" I want to work with "toggle-div-1"
"button-2" I want to work with "toggle-div-2"

etc etc.

The number of sets, and the IDs used, will be different each time.

I'm sure there is a standard way to use JQuery on elements that have been created dynamically by php but I have not found a good working example yet.

Any help would be appreciated.


Thank you.