简体   繁体   中英

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM