I have a handmade responsive jQuery grid, elements in this grid are DIV's with float:left
.
Their widths and number in a row are calculating on their container width changes. For example if container width 500px, than it can keep 4 elements in a row, elements width calculated accordinaly as 25%, if container width changes to 400, it can keep only 3 in a row with width 33%.
The calculation is not important, the question is what is the fastest way to change container's elements style? Now I do straitforward
$('.container .element').css({width:'25%'});
As I understand jQuery iterates each element and changes it's style. But what if I could dynamicly create a style:
.container.foo .element {width:25%;}
And just add .foo
class to my container, than I guess this operation would be forced by browser, and it could be much faster.
Is it? Is it possible?