Forum Moderators: open

Message Too Old, No Replies

show or hide dynamic divs

         

Tk_liv

10:27 am on May 22, 2011 (gmt 0)

10+ Year Member



Hi
I have stored different html table inside diffrent divs.This divs are dynamically generated.like(div id="more1_sp",div id="more2_sp",div id="more3_sp").default state of this divs are hidden.Now above these each divs(in php page), there are another dynamically generated divs like(div id="more1" div id="more2" div id="more3").Now I want when user click on "more1" it will show/hide the corresponding div like "more1_sp".kind of accordion effect.I don't familiar with the jquery syntax. Any help would be great help
Thanks in advance

JAB Creations

9:51 pm on May 22, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use the following with the element's ID. Remember you can use more than one class by using spaces (as demonstrated below).

- John

Function
function change(id, newClass) {if (document.getElementById(id)) {document.getElementById(id).className=newClass;} else if (id) {id.className=newClass;} else {alert('Error: the id \''+id+'\' was not found or has not yet been imported to the DOM.\n\nNew class intended: '+newClass);}}


Usage
change('more1_sp','new_class1 new_class2');
change('more2_sp','new_class1 new_class2');