I have elements. I know for sure they will have a class 'fc-id#' where '#' is a number.
I need to somehow get that number. This will always be the first class of the element.
Is there some way to get the number at the end?
Thanks
I have elements. I know for sure they will have a class 'fc-id#' where '#' is a number.
I need to somehow get that number. This will always be the first class of the element.
Is there some way to get the number at the end?
Thanks
use .split()
method like
var idNum = $(this).attr('class').split('id')[1]; // #
or if you need to retrieve the first class do like:
var idNum = $(this).attr('class').split(' ')[0].split('id')[1]; // #
$("[class^=fc-id]").each(function(){
// Everything after the first 5 characters (fc-id)
alert($(this).attr("class").substring(5));
})