Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

search box enter key javascript

document.getElementById("id_of_textbox")
    .addEventListener("keyup", function(event) {
    event.preventDefault();
    if (event.keyCode === 13) {
        document.getElementById("id_of_button").click();
    }
});
Comment

javascript on enter search

<div class="box">
  <div class="container-1">
    <form id="something">
      <input name="search" placeholder="Search... type ENTER to submit or use the button -->">
      <input type="submit"> 
    </form>
    <div class="icon"  ></div>
   </div>
</div>
 Run code snippet
Comment

javascript on enter key searchbox

// Bind Enter key to search bar
$("#MySearchBar").keypress(function (e) {
  if (e.keyCode === 13) {
    MyVoidFunction();
  }
});
Comment

javascript on enter search

function search(query){
   query.preventDefault();
   let vquery = query.target.elements["search"].value;
   console.log(vquery)
   
}

something.addEventListener("submit", search, false)
Comment

javascript on enter search

function search(query){
   query.preventDefault();
   let vquery = query.target.elements["search"].value;
   console.log(vquery)
   
}

something.addEventListener("submit", search, false)
Comment

javascript on enter search

<div class="box">
  <div class="container-1">
    <form id="something">
      <input name="search" placeholder="Search... type ENTER to submit or use the button -->">
      <input type="submit"> 
    </form>
    <div class="icon"  ></div>
   </div>
</div>
 Run code snippet
Comment

javascript on enter search

<div class="box">
  <div class="container-1">
    <form id="something">
      <input name="search" placeholder="Search... type ENTER to submit or use the button -->">
      <input type="submit"> 
    </form>
    <div class="icon"  ></div>
   </div>
</div>
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular command to create interceptor 
Javascript :: getServerSideProps cookie 
Javascript :: javascript loop through objec 
Javascript :: js select on change value 
Javascript :: How to Keep the Current Tab Active on Page Reload 
Javascript :: javascript object syntax example with find 
Javascript :: show div with jquery 
Javascript :: javascript prompt to integer 
Javascript :: tab navigation react-native without title 
Javascript :: javascript execute code on page load 
Javascript :: fill array with random numbers javascript 
Javascript :: json stringify indent 
Javascript :: match date regex 
Javascript :: react native get current time 
Javascript :: angular lifecycle hooks 
Javascript :: javascript iterate array 
Javascript :: arrow function forms in javascript 
Javascript :: javascript round decimal 
Javascript :: set an attribute background image javascript 
Javascript :: object to json javascript 
Javascript :: calculate string value in javascript, not using eval 
Javascript :: Get parent directory name in Node.js 
Javascript :: static folder express 
Javascript :: js replace all spaces 
Javascript :: angular download blob pdf 
Javascript :: javascript sort array alphabetically 
Javascript :: javascript redirect function 
Javascript :: select a random element from from items array 
Javascript :: regex for entire word 
Javascript :: hashnode.com 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =