Updated code to add class to dom elements after they are created to support IE8