var id = parseInt($(this).attr('id).substring($(this).attr('id').lastIndexOf('-')+1));
The above example .split() also works, but you will need to grab the highest index in the array if you specify an identifier with more than 1 dash: subsection-11
source share