Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

click button when press enter javascript

var input = document.getElementById("myInput");

// Execute a function when the user releases a key on the keyboard
input.addEventListener("keyup", function(event) {
  // Number 13 is the "Enter" key on the keyboard
  if (event.keyCode === 13) {
    // Cancel the default action, if needed
    event.preventDefault();
    // Trigger the button element with a click
    document.getElementById("myBtn").click();
  }
});
Comment

on enter press button

<input onkeyup="if(event.keyCode===13){submit.click()}"><button id="submit">submit</button>
Comment

button onclick enter key

$("#id_of_textbox").keyup(function(event) {
    if (event.keyCode === 13) {
        $("#id_of_button").click();
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: jest mock react-redux hooks 
Javascript :: prevstate in usestate 
Javascript :: format date month day year javascript 
Javascript :: jsx foreach 
Javascript :: jquery select a dynamic element 
Javascript :: onclick on non button 
Javascript :: android force date inside RecyclerView to re render 
Javascript :: how to wait a determined amount of time before doing something in js 
Javascript :: read and update csv file in nodejs 
Javascript :: xmlhttprequest pass parameters post 
Javascript :: iseet jquery 
Javascript :: javascript sessionstorage 
Javascript :: how to use static files in express with ejs 
Javascript :: javascript if has jquery loaded 
Javascript :: javascript add listeners to class 
Javascript :: javascript quicksort 
Javascript :: convert model object to json django 
Javascript :: react history go back 
Javascript :: moment timezone get timezone offset 
Javascript :: how to get file extension in javascript 
Javascript :: js add to array if not exists 
Javascript :: discord.js arguments 
Javascript :: js how to remove # from any url using js 
Javascript :: angular 404 on refresh 
Javascript :: regex not contains 
Javascript :: clear swr cache 
Javascript :: function(a, b){return b - a} 
Javascript :: jquery count selected options 
Javascript :: Disable Initial Sorting in Datatable 
Javascript :: js input type range on hover 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =