How can I get last characters of a string using JavaScript?

You’ll want to use the Javascript string method .substr() combined with the .length property.

var id = "ctl03_Tabs1";
var lastFive = id.substr(id.length - 5); // => "Tabs1"
var lastChar = id.substr(id.length - 1); // => "1"

This gets the characters starting at id.length – 5 and, since the second argument for .substr() is omitted, continues to the end of the string.

If you’re simply looking to find the characters after the underscore, you could use this:

var tabId = id.split("_").pop(); // => "Tabs1"

This splits the string into an array on the underscore and then “pops” the last element off the array (which is the string you want).