user1716672
user1716672

Reputation: 1073

Get value after hash with Jquery BBQ

I'm using Jquery BBQ as I want to get the value after a hash in a url. So I have:

            var url = $(this).attr('href');

            console.log(jQuery.deparam.fragment(url));

When I explore the log I see:

Object
131: undefined
__proto__: Object
__defineGetter__: function __defineGetter__() { [native code] }

Etc Etc.

The number 131 is the value after the hash I want, I just can't seem to get at it (I'm pretty new to Jquery). So how can I get at the value, in this case 131? This is probably very easy...

Upvotes: 0

Views: 1583

Answers (1)

tcovo
tcovo

Reputation: 7740

From the jQuery BBQ documentation:

jQuery.deparam.fragment( [ url ] [, coerce ] )

Parse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.

Returns: (Object) An object representing the deserialized params string.

so if you just want the entire fragment as a string you can use:

jQuery.param.fragment( [url] )

Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.

Returns: (String) The parsed fragment (hash) string, with any leading “#” removed.

Upvotes: 1

Related Questions