0
How can i create many html elements and control its property by js
5 Réponses
+ 17
let container = document.getElementById("container");
for(let i = 0; i < 10; i++){
let newEl = document.createElement("p");
newEl.innerHTML = `i am paragraph #${i + 1}`;
container.appendChild(newEl);
}
+ 9
https://htmldog.com/guides/javascript/advanced/creatingelements/
https://www.tutorialrepublic.com/javascript-tutorial/javascript-dom-manipulation.php
https://webplatform.github.io/docs/tutorials/manipulating_css_with_javascript/
https://www.w3.org/wiki/Dynamic_style_-_manipulating_CSS_with_JavaScript
0
I want to repeat the same element by js instead of write it in html a lot of times