Lets say I have this in my html:
<div id="myDiv" class="a b-32"/>
I'm trying to get the index of 'b' class (in my example '32')
The only way I know how to do it is by:
var index;
var myDiv = $("#myDiv").attr("class");
var classes = myDiv.split(' ');
for(var i=0; i<classes.size(); i++){
if(classes[i].matches((b-)+[\d]*) ){
index = classes[i].replace("b-","");
}
}
alert(index);
Is there any solution that doesn't imply iterating all the classes manually? Because my solution seems dull. Surely there must be a better way, I just can't find it.