+ 2
Generate div with class using jquery/javascript?
I am trying to add 100 div elements with same class using js/jquery. I can't seem to make it work. Also is there a way to increment left margin of each element (first div with class="x" has a margin of 1px, the next div with class=x" should have a margin of 2px etc.) thank you!
1 Answer
+ 10
Probabil te ajuta aceasta solutie care nu foloseste jquery :)
var divs = [];
for (var i=0; i<100; i++) {
divs[i] = document.createElement("div");
divs[i].className = "myClass";
}