I have a webpage populating with a variable number of the same class elements. I want to set the left and right margins for every second, 5th, 8th, 11th, etc. Classes (if any).
Is there any way to achieve this using javascript? I do not want to use the css3 child selector as it is not compatible with older browsers.
My divs are arranged as follows:
[div class = "block"] [div class = "block"] [div class = "block"]
[div class = "block"] [div class = "block"] [div class = "block"]
[div class = "block"] [div class = "block"] [div class = "block"]
[div class = "block"] [div class = "block"] [div class = "block"]
I want each middle div to have a margin on the left and right.
Thanks.:)
source
share