jQueryで現在開いているページのURLの一部を取得して、body class="ココ" に入れちゃえという話。
jQueryプラグイン jQuery-URL-Parserについて
jQuery-URL-Parserは、URLをパースしてくれるjQueryのプラグインです。
以下は簡単にどこを取れるか書いています。詳しくはjQuery-URL-Parserで確認してくださいね。
- URL attributes 「
.attr()
」
https://example.com/folder/dir/index.html?item=value
・/folder/dir/index.html
・/folder/dir/
・index.html - Query string parameters 「
.param()
」
https://example.com?sky=blue&grass=green
・'blue'
・'green'
・'grass':'green' - URL segments 「
.segment()
」
https://example.com/folder/dir/example/index.html
・'folder'
・'example' - Fragment parameters and/or segments 「
.fparam()
」 「.fsegment()
」
https://example.com#sky=blue&grass=green
・'blue'
https://example.com/#/about/us/
・'about'