I have a problem and I am not sure how to solve it or if it’s even possible: in WordPress I have built a simple event calender. Now I want to style every first event of a certain date. How can I select this first event?
https://arneteubel.com/kunden/rz-test/termine/
This is the demo page. Every event gets it’s date as a class so what I am looking for is something like:
- Find elements with the same class
- Select the first element and apply a style
I can not group my events by date…
Now is that even possible? Maybe with PHP or jQuery?
Thank you!
2
Answers
I prefer to work with
data-
attribute instead of classesdata-date="feb34454"
instead ofclass="feb34454"
See the next example
Note: Don’t forget to include jquery
You should use CSS for styles if at all possible.
Here’s a CSS solution stolen from this answer:
… then "undo" the styles for elements with the class that come after the first one, using the general sibling combinator ~ in an overriding rule: