通过锚点从一个输入框获取数据到另一个页面上的另一个输入

Get data from one input box to another input on another page via anchors

我在索引页面上有一个搜索输入框,我希望它重定向到搜索页面并自动用输入框中的文本填充搜索框,然后手动触发 .keyUp() 事件。
我是 javascript 和 html 的初学者所以请原谅我的编码不佳。
这是我 index.html 页面的当前代码:

<div class="address-bar">
    <input id="search-text" type="text">
    <button id="search-enter">Search</button>
</div>

我对该页面的 javascript 是:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>

    var searchquery = $("#search-text")
    $("#search-enter").click(redirect)
    function redirect() {
        window.location("http://<example>.com/search.html#q=" + searchquery + "E")
    }
</script>

我目前正在使用 Matt york's fuzzy search libary。 我在其他页面上的代码是:

<h1>Search:</h1>
<input type="text" id="search" class="search"></input>
<div id="characters">
</div>

与javascript:

<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script>
var anchor = window.location.hash()
var question = anchor.substring(3, -1)

试试这个

$('.search').val(question);
$('.search').keyup();

那是说您可能想为输入元素指定一个 ID。