Javascript DOM onsearch Event via HTML Tag onsearch attribute

Introduction

This example demonstrates how to assign an "onsearch" event to an input element.

Write something in the search field and press "ENTER".

The onsearch event is not supported in Internet Explorer, Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="search" id="myInput" onsearch="myFunction()">
<p id="demo"></p>

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

</body>
</html>
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <input type="search">



PreviousNext

Related