Check if element is there before checking for class attribute