|
|
|
|
|
by Nadya
3888 days ago
|
|
I've never understood separating by odd/even. Typically the people who do this only want to add styles to "alternate" rows. So I would use 'class="alternate"'. >Basically, I need to see some more examples to understand the distinction better. Personally I do it only for organizational purposes more than anything else. The "actual use cases" are a bit contrived if I'm being honest, at least for this example. Let's say you have 5 photos on a page, each with different filters applied on different locations of the page. You want to allow users to normalize the page by selecting a single filter to apply to every photo. I'm not a JS expert - but the first seems a lot easier to manipulate multiple images at once. A single check of img.dataset.filter instead of checking against an entire array of classes. (If there is a simpler way of checking the class example, I'm all ears.) <img src="/" data-filter="oldschool" class="medium"> //change to greyscale
<img src="/" data-filter="fuchsia" class="large"> //change to greyscale
<img src="/" class="large"> //not to be changed
<img src="/" data-filter="1970" class="small"> //change to greyscale
<img src="/" class="medium oldschool"> //change to greyscale
<img src="/" class="large fuchsia"> //change to greyscale
<img src="/" class="small"> //not to be changed
<img src="/" class="small 1970"> //change to greyscale
|
|
I don't think a fear of javascript should be driving decisions about markup. You should write your markup in the clearest, most semantic way possible, and let what are ultimately trivial js problems take care of themselves.