Php 点击回车键触发一个按钮
根据此代码,如果我按enter键,它将返回警报。但我想做一个代码,通过它我可以按下键盘,它将重定向到一个页面Php 点击回车键触发一个按钮,php,jquery,html,Php,Jquery,Html,根据此代码,如果我按enter键,它将返回警报。但我想做一个代码,通过它我可以按下键盘,它将重定向到一个页面 <!DOCTYPE html> <html> <body> <h3>Trigger Button Click on Enter</h3> <p>Press the "Enter" key inside the input field to trigger the button.</p> <inp
<!DOCTYPE html>
<html>
<body>
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<button id="myBtn" onclick="javascript:alert('Hello World!')">Button</button>
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode === 13) {
document.getElementById("myBtn").click();
}
});
</script>
</body>
</html>
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
触发按钮点击回车键
按输入字段内的“回车”键触发按钮
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
按钮
var input=document.getElementById(“myInput”);
input.addEventListener(“键控”,函数(事件){
event.preventDefault();
如果(event.keyCode===13){
document.getElementById(“myBtn”)。单击();
}
});
我如何定制它。请帮助这应该是您所需要的一切:
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
触发按钮点击回车键
按输入字段内的“回车”键触发按钮
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
var input=document.getElementById(“myInput”);
input.addEventListener(“键控”,函数(事件){
event.preventDefault();
//一把钥匙,如果是每把钥匙,请将其取下
//或者用这个来找到你想要的钥匙码http://keycode.info/
如果(event.keyCode==65){
location.href=”https://google.com";
}
});
将65用于键“A”
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
触发按钮点击回车键
按输入字段内的“回车”键触发按钮
<h3>Trigger Button Click on Enter</h3>
<p>Press the "Enter" key inside the input field to trigger the button.</p>
<input id="myInput" value="Some text..">
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// a key, remove if for every key
// or use this to find your wanted keycode http://keycode.info/
if (event.keyCode === 65) {
location.href = "https://google.com";
}
});
</script>
</body>
</html>
按钮
var input=document.getElementById(“myInput”);
input.addEventListener(“键控”,函数(事件){
event.preventDefault();
如果(event.keyCode===65){
//重定向到任何页面
}
});
Changedocument.getElementById(“myBtn”)。单击()代码>到window.location=”http://google.com“
。如果(event.keyCode==65){location.href=“”;}他想使用“a”而不是“enter key”,我已经在中编辑了它,但万一他想要另一个键,请阅读注释