這是按鈕創建的按鈕,當用戶單擊搜索選項卡時,該按鈕具有可進入頁面的功能,但我需要它在用戶壓力機也進入。如何在用戶按下輸入時使搜索工作
這是搜索欄和按鈕
<input type="text" method="get" class="form-control" id="search" placeholder="Search" value="">
<button type="button" id="go" class="btn btn-default" onclick="sendToPage();">Search</button>
這是函數
function sendToPage(){
var input = document.getElementById("search").value;
//Check to see if the user has entered apple/iphone;
if (input === "apple"){
//location.href="apple.html";
location.replace("apple.html");
return false;
}
else if (input === "iphone"){
location.replace("apple.html");
return false;
}
}
你的按鈕點擊代碼在哪裏?或者什麼是按鈕名稱? –