Q:

How to get the text after the # symbol in a link?

I have a simple link with a hashtag in it. ie:
<a class="page_navigation" href="#something">click</a>

On clicking this, I would like to just end up with the 'something' part (minus the hash) in a var.
So far I have
$('.page_navigation').click(function(e)
{
    e.preventDefault();
    var href = $(this).attr('href');
});

Obviously I just end up with '#something' in my href var with the above code, and I understand I could do some kind of regex (not sure how yet) to strip the #, but I wonder if there is an easier way to access this part of the href I'm unaware of, without having to go through some find and replace code.
Any ideas?
Note: I also know I could store the 'something' in a data tag, but I'm trying to keep this code as DRY as possible.

A:

If you know it has a # in it, you can use this:
$('.page_navigation').click(function(e)
{
    e.preventDefault();
    var hash = this.href.replace(/^.*#/, "");
});

If you don't know whether it has one it it or not, you can use this:
$('.page_navigation').click(function(e)
{
    e.preventDefault();
    var hash = "";
    if (this.href.indexOf("#") {
        hash = this.href.replace(/^.*#/, "");
    }
});

In HTML5, you could use:
this.hash

but that is only for the latest browsers.

