I have selected the following item. What is the best way to get the class name icon_23123?
<div class="icon icon_23123"></div>
Is there something like [class ^ = "icon_"] for selecting attributes instead of elements? Or should I get all the class names and scroll to find the one that starts with the _ icon?
EDIT: I want to write a function that gets any class name, starting with the letter "icon_", and only those class names. Ultimately, I want to get the part after the underscore, but it's not necessarily a number — my plan was to use a regular expression (these class names are regular.)
EDIT2: the element that I am trying to get from the class name is already selected, I just need the class name from it (not every element in the document with the symbol class = _..... ").
EIDT3: My real problem was that I was mixing data and style. Since I do not want to support older browsers, I use the data identifier to store the identifier of this database.
<div class="icon icon_23123" data-id="23123"></div>
source
share