var $target = $container.children().last();$target.find('.dot, .triangle, .textcon').each(function (i, n) { var $this = $(n); switch(n.className) { case 'dot': $this.addClass('error-dot'); break; case 'triangle': $this.addClass('error-triangle'); break; case 'textcon': $this.addClass('error-textcon'); break; }});