Reputation: 169
I use a plugin for my portfolio page which uses hash to sort/filter items. also, I need to send a class name to url with hash. can I get the two hash values with jquery? if this is not possible, what is alternative solution to send the class name to url? (I don't want to set cookies)
Upvotes: 1
Views: 302
Reputation: 22974
I am explaining the basic logic of inserting and extracting ahash values.
$(location).attr('href') will give you the current url.
Then append two hash values using
$(location).attr('hash','FirstHashValue');
var RequiredClassName = 'NameYouWantToAppend';
$(location).attr('hash','FirstHashValue'+'#'+RequiredClassName);
Extract these values from Jquery
var hashes = $(location).attr('hash')
hashes.split('#')
hashes array will contain all the # values and one extra empty hash value at the beginning.
I tried this. It works. But let me know if anything is wrong.
Upvotes: 1