I know that this might be a stupid question but it drives me crazy. I\'m trying to change the innerHTML of a DOM element but it doesn\'t change until the end of the function