I want to submit input details by clicking enter but in 5 sec here is the code please add timing in the code
document.addEventListener("DOMContentLoaded", () => {
inputValue.addEventListener("keydown", (e) => {
if (e.code === "Enter")
{
let input = inputValue.value;
inputValue.value = "";
output(input);
}
});
});
CodePudding user response:
document.addEventListener("DOMContentLoaded", () => {
inputValue.addEventListener("keydown", (e) => {
if (e.code === "Enter")
{
setTimeout(()=>{
let input = inputValue.value;
inputValue.value = "";
output(input);
}, 5000)
}
});
});
CodePudding user response:
Use setTimeout
setTimeout(_=>{
if (e.code === "Enter")
{
let input = inputValue.value;
inputValue.value = "";
output(input);
}
}
, 5000);
CodePudding user response:
document.addEventListener("DOMContentLoaded", () => {
inputValue.addEventListener("keydown", (e) => {
if (e.code === "Enter")
{
var timer = setTimeout(()=>{
let input = inputValue.value;
inputValue.value = "";
output(input);
}, 5000)
}
});
});