开发者

Populate a jQuery search input by URL

quick question here.

I'm looking for a way to populate my JQuery search box, with the value entered in the URL.

So I have a URL that looks someth开发者_运维百科ing like this :

http://**/pub/3/site/ti/store/mobile/page/productList.page

now if I enter something like this at the end

http://*/pub/3/site/ti/store/mobile/page/productList.page?=brand

I`d like this to appear in my search box. How could I accomplish that ?

Thanks in advance.


You can access location.search, which does include the ? though.

$('input').val(location.search.substring(1)); // set input value to the
                                              // ?... data, omitting the ?

http://jsfiddle.net/Y9kdU/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜