Reputation: 13
I am facing some problem to get the class name of a div. For example my html is like that...
<div class="rating-static rating-48 "></div>
<div class="rating-static rating-40 "></div>
I need to get the value ,for example 48 Don't know if it is possible or not.
Upvotes: 0
Views: 121
Reputation: 18873
You can try this :-
$('div.rating-static').each(function(){
var value = $(this).attr('class').split('-')[2];
alert(value);
});
OR
$('div.rating-static').each(function(){
var value = $(this).attr('class').substring($(this).attr('class').lastIndexOf('-') + 1);
alert(value);
});
Upvotes: 1