`onsearch` 事件在 JavaScript 中的用法是什么?
`onsearch` 事件适用于搜索,即用户在输入元素中按下了回车键或“x”键。`` 的类型为搜索,因为是供用户用来进行搜索的。Internet Explorer、Firefox 和 Opera 不支持 `onsearch` 事件。
示例
你可以尝试运行以下代码,以了解如何在 JavaScript 中实现 `onsearch` 事件。
<!DOCTYPE html>
<html>
<body>
<p>Write what you want to search below and press "ENTER".</p>
<input type = "search" id = "newInput" onsearch = "searchFunc()">
<script>
function searchFunc() {
var a = document.getElementById("newInput");
document.write("Searched = " + a.value);
}
</script>
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 程序设计
C++
C#
MongoDB
MySQL
Javascript
PHP