For beginner projects, you have a choice. You can:
Use an existent framework, such as AngularJS or React.
The benefit is that it will force you to organize your project in a very specific way, and while you could make choices when you gain enough experience, you can also avoid making any structure choice when you're a beginner, and follow the default structure of the framework.
The drawback is that additionally to the complexities of the technologies and protocols used in web development, you add the complexity of the framework itself. Personally, I think the complexity of frameworks with a rigid structure, such as Angular, are too overwhelming for a person who is new to web development.
Work from scratch, but pick a popular architecture or pattern, such as MVC.
The benefit, once again, is that you're pretty sure that the architectural choices which were made for you are probably the good ones—better than what somebody without deep knowledge of web architecture could make.
The drawback is that you have to grasp those architectures/patterns, and clearly understand how they should be applied in a context of web development.
Go from scratch, work in iterations, produce something which works, and see where it all ends.
If you do that, don't expect to have a production-ready application. Instead, prepare to throw it away several times, and restart all the process once you learn enough to understand where you made structural mistakes which cannot be easily refactored.
Through the learning process, make sure:
You check the open source projects to see how they were built.
I started programming in C and am used to writing a set of functions that carry out a task but not sure this is suited to JS/HTML as I have done it.
I feel sure this is a poorly structured way of doing it.
Your piece of code looks fine to me. However, one needs to look at the larger project to have a good understanding of the quality of the code.
Don't hesitate, by the way, to submit larger pieces of code to CodeReview.SE. People from there would be glad to help you, telling which things could be improved.