Check for element existence before attempting to change styles