Skip to content

cloudcome/jquery.hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery.hash


spm version

jquery.hash 监听、设置、获取hash


Install

$ spm install jquery.hash --save

Usage

It is very easy to use this module.

// require jquery
var $ = require('jquery');

// extend jquery
require('jquery.hash')($);

// use
$.hash();

HashType

HashType !

#!a/1/b/2/c/3

HashType ?

#?a=1&b=2&c=3

Api

Options

$.hash.defaults = {
    // 传入hash值,为空时默认为当前window.location.hash
    hash: '',
    // 默认hashtype
    type: '!'
}

Functions

get

$.hash().get();
$.hash().get("a");
$.hash().get(["a", "b"]);

set

$.hash().set("key", "val");
$.hash().set({
	"key1":"val1",
	"key2": "val2"
});

remove

$.hash().remove("key");
$.hash().remove(["key1", "key2"]);
$.hash().remove();

stringify

$.hash().set("key", "val").remove("a").stringify("!");
$.hash().set("key", "val").remove(["a", "b"]).stringify("?");

location

$.hash().set("key", "val").remove("a").location("!");
$.hash().set("key", "val").remove(["a", "b"]).location("?");

listen

// listen one
$.hash().listen("key", fn);

// listen or
$.hash().listen("key1", "key2", fn);

// listen both
$.hash().listen(["key1", "key2"], fn);

// listen all
$.hash().listen(fn);

get suffix

$.hash().suffix();

set suffix

$.hash().suffix('123');

Demo

http://spmjs.io/docs/jquery.hash/examples/index.html

History

http://spmjs.io/docs/jquery.hash/history.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published