This happens because you are toggling the .panel class. The browser doesn't know better than to select all .panel elements and toggle them.
- Instead of the $('.panel') selector, use DOM traversal methods to travel from the .flip element to its corresponding .panel element. For example if the .panel element comes right after its .flip element, which is the case in your example, you can use $(this).next() to access the .panel.
- Another option is to assign unique ids for all of the .flip and .panel elements. For example, give .flip ids of flip1, flip2, etc and give .panel ids of panel1, panel2, etc. then you access the proper .panel using this selector: $('#panel'+$(this).attr('id').substr(4))
- You could also improve the above id system by using the .eq() function.
Leave a comment on youri.bok's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic