Just a tip and forgive my horrible english kkk 
Usually there are some conventions on how to manipulate the DOM, there are also frameworks that remove the Responsibility of the Developer to manipulate the DOM directly, there are several good and interesting examples, React, Vue, Angular, Ember and etc.
When you have a time it is worth to understand the proposals of these tools
obs: First of all, learn the vanilla javascript correctly.
Any questions just post here 