If you have 20 pictures (class of .picture) and 20 hidden items (class of .addcomment), then when you click on the 3rd picture, then it will show the third .addcomment.
This is instead of naming 20 different classes.
1 2 3 4 |
var idx = $('.picture').index(this); $('.addcomment').eq(idx).show(); |