How to detect if more than one detail tags with the same class exist next to each other?

How to detect if more than one detail tags with the same class exist next to each other?

I want to detect if the page contains more than one details tag with the same class names that are next to each other. If so, I need to modify the details tag to include additional attributes. I'm new to jquery so any help is appreciated.