I’m having some difficulties with getting the value of a subclass in a element. Generally, I’d verify with .hasClass or .attr("class") and then compare it, but I’m trying to get the value of a dynamically generated subclass.
Let’s say that I have a class="edit step1". I have to get only the step1 part but it must not depend on the number at the end, since it can be anything. I tried with .hasClass("~step") and some other functions but no dice.
Has anyone ever encountered a situation where this would be needed and has a solution but even any tip as to where I should look would be greatly appreciated.
Thanks!
It’s not a great use for classes, particular since they’re already stored in an unstructured way within the element attributes. this would be a great use for “data-step” tags.
If you can count on the names being structured, your best bet might be to split the class list and look at each element.
If you’re stuck with this sub-optimal situation, the above might work