Execute a JavaScript when submitting a search: - Javascript DOM Event

Javascript examples for DOM Event:onsearch

Description

Execute a JavaScript when submitting a search:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="search" id="myInput" onsearch="myFunction()">

<p id="demo"></p>

<script>
function myFunction() {//from  w ww.  j a  v a  2  s  .co m
   var x = document.getElementById("myInput");
   document.getElementById("demo").innerHTML = "You are searching for: " + x.value;
}
</script>

</body>
</html>

Related Tutorials