function tellMyName() {
var str = this.href.split("#")[1];
alert(str);
}
Not all the time only the hash part will be displayed on the link. Sometimes the Host is added to the href
. By splitting the href with the hash
(#) and get the second part of the split string, you'll get what you want.