这是按钮创建的按钮,当用户单击搜索选项卡时,该按钮具有可进入页面的功能,但我需要它在用户压力机也进入。如何在用户按下输入时使搜索工作
这是搜索栏和按钮
<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;
}
}
你的按钮点击代码在哪里?或者什么是按钮名称? –