You can't have duplicate id's. All ids need to be unique.
Because you have duplicate id's, JavaScript / jQuery only uses the first element with the id #am-container
.
So you need to change your elements to have a classname.
The selector then would be var $container = $('.am-container')
instead of var $container = $('#am-container')