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/
精彩评论