1
2 // Get the input field
3var input = document.getElementById("myInput");
4
5
6input.addEventListener("keyup", (event) => {
7 if (event.key === "Enter") {
8 // Cancel the default action, if needed
9 event.preventDefault();
10 // Trigger the button element with a click
11 document.getElementById("myBtn").click();
12 }
13})
1
2 // Get the input field
3var input = document.getElementById("myInput");
4
5
6input.addEventListener("keyup", (event) => {
7 if (event.key === "Enter") {
8 // Cancel the default action, if needed
9 event.preventDefault();
10 // Trigger the button element with a click
11 document.getElementById("myBtn").click();
12 }
13})
14
15$('.container').on('keydown', 'input', function(e) {
16 if (e.keyCode === 13) {
17 e.preventDefault();
18 e.stopImmediatePropagation();
19 //Do your stuff...
20 }
21});
1$('.container').on('keydown', 'input', function(e) {
2 if (e.keyCode === 13) {
3 e.preventDefault();
4 e.stopImmediatePropagation();
5 //Do your stuff...
6 }
7});