The id is supposed to be unique (reference)
In your example, all container IDs are equal to "expandedimg". If you change each container id to something unique, maybe pass it as a parameter, it should work just fine.