gpt4 book ai didi

javascript - 通过 URL 填充 jQuery 搜索输入

转载 作者:行者123 更新时间:2023-11-30 18:41:48 24 4
gpt4 key购买 nike

在这里快速提问。

我正在寻找一种方法来使用在 URL 中输入的值来填充我的 JQuery 搜索框。

所以我有一个看起来像这样的 URL:

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

现在如果我在最后输入这样的内容

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

我希望它出现在我的搜索框中。我怎样才能做到这一点?

提前致谢。

最佳答案

您可以访问location.search ,其中确实包含 ?

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

http://jsfiddle.net/Y9kdU/

关于javascript - 通过 URL 填充 jQuery 搜索输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6650279/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com