From the following markup.
Somewhere Somewher
I usually do something like this:
$("#my-div a").click(function(){ var match; if (match = $(this).attr('id').match(/link-(\d+)/)) { var number = parseInt(match[1],10); alert(number); } });