What is the best practice to make the Javascript code to add some html content ?
For example with the Twitch API challenge I want to add a panel with different information for each channel.
- I used a Javascript function to create and manipulate DOM content (using createElement, appenChild…) which took a lot of a bit messy code lines.
- An other way would have been to write some html code within my javascript (something like var element = “< div >…< /div >”; but i hear it’s bad practice to use html code in javascript file and vice versa.
- A third way would have been to write in the html an empty skull and then use JQuery to fill this skull for first element and for the next ones to do a clone of it and modify it.
Do you see other way to do that ? What would be the best way according to you and why ?