I've got something like this, but it doesn't work:
<!-- ... code .. -->
var id = 0;
data.forEach(function(item, i) {
id = id+1;
$( ".button-" + id ).click(function() {
$( ".button-" + id ).toggle();
});
<!-- ... code .. -->
What I want: There are some DIVs like button-1, button-2 ... and so on. I made an toggle and I wanted to automate it with this loop, because the content is dynamically generated. But this seems to be the wrong way... In this loop it does not work.
So how to make toggles dynamically for button-1, button-2, ... ??
It's just about this, which seems to be wrong:
$( ".button-" + id ).click(function() {
$( ".button-" + id ).toggle();
EDIT
Well, maybe my question was a little bit messy