From the following markup.
Somewhere Somewher
You can use a regular expression to parse out the number:
var match = /link-(\d+)/.exec($(this).attr('id')); var num = match[1];