Reputation: 953
Here's my problem: I have a class defined in CSS:
.myclass {height: 10px; width: 10px}
But in my script file,I append one parent div with the child divs of this class. And the total number and sizes of each div are calculated with jQuery. So the given size 10px is changing. But when the number of divs is higher than 50 my browser crashes, because when I use
$('.#parentDiv').children().last().width(CalculatedSize).height(CalculatedSize);
I pick with every iteration all the div's and rearranging their sizes (If i understand this correctly).
Is there a method to change not the class of each selector each time, but to edit the existing css class in general BEFORE adding elements with this class, and then append a parent div with already redefined in size and number child divs?
Here's the code with which I append my parent div
while ( i<=N ) {
$('#parentDiv').append('<div class="myclass"></div>');
$('#parentDiv').children().last().width(CalculatedSize).height(CalculatedSize);
i++;
CalculatedSize - is a function.
Upvotes: 2
Views: 52
Reputation: 953
But when the number of divs is higher than 50 my browser crashes
turned out that the problem was that i used a FUNCTION to calculate a cell size. When I tried to use variable for it, everything worked much faster.
Upvotes: 2