The onsearch
attribute event is triggered
when a user does the search by pressing the ENTER key
in an <input> element with type="search"
.
We can also trigger the event by clicking 'X' inside the field.
None.
<elementName onsearch="script">
<input type="search">
onsearch |
Yes | No | No | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<!--from w w w .j a v a 2 s. c o m-->
<input type="search" id="myInput" onsearch="myFunction()">
<script>
function myFunction() {
var x = document.getElementById("myInput");
console.log(x.value);
}
</script>
</body>
</html>