`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