I am dynamically generating elements:
<a class="gallery1" href="base64String">
<img src="base64StringThumbnail">
</a>
where numerical value suffix to gallery
changes, I can't predict the numerical value ahead of time, so the regex for the class would be "gallery\\d+"
.
I'd like get just all the classes without duplicates that match that regex
So I could write something like that:
$(document).ready(function () {
for(const clazz in matchedClasses){
$('.' + clazz).createGallery();
}
});
For instance if I have elements with classes: gallery1, gallery2, gallery1, gallery3, gallery2
in DOM, I would get:
[gallery1, gallery2, gallery3]
in any order.
that's easy for me in C# and Java, but I don't know how to achieve that in JS.