Demo
Retrieving all hash parameters
Hash
#category=outdoors&subCategory=hiking&product=packs
Code
var hashParameters = $.fn.hashparam();
At Runtime
hashParameters = {
category: "outdoors",
subCategory: "hiking",
product: "packs"
};
Retrieving a hash parameter value
Hash
#q=hiking+back+packs
Code
var query = $.fn.hashparam("q");
At Runtime
query = "hiking back packs";
Set multiple hash parameters in one call
Previous Hash
#
Resulting Hash
#category=new&page=10&order=DESC
Code
var hashParameters = {
category: "new",
page: 10,
order: "DESC"
};
$.fn.hashparam(hashParameters);
Set a particular hash parameter value
Previous Hash
#page=1
Resulting Hash
#page=1&enabled=true
Code
$.fn.hashparam("enabled", true); // Boolean value
Previous Hash
#
Resulting Hash
#title=The+Story+of+Life
Code
$.fn.hashparam("title", "The Story of Life"); // String value
Previous Hash
#count=15
Resulting Hash
#count=27
Code
$.fn.hashparam("count", 27); // Number value
Remove a particular hash parameter
Previous Hash
#category=outdoors&subCategory=camping
Resulting Hash
#category=outdoors
Code
var subCategory = $.fn.hashparam.remove("subCategory");
At Runtime
subCategory = "camping";
Remove all hash parameters
Previous Hash
#category=outdoors&subCategory=hiking&product=packs
Resulting Hash
#
Code
var previousHashParameters = $.fn.hashparam.clear();
At Runtime
previousHashParameters = {
category: "outdoors",
subCategory: "hiking",
product: "packs"
};