Replaced forEach with jQuery's $.each to support browsers without native support of forEach