JavaScript中onsearch事件的用途是什么?
onsearch事件对于搜索非常有用,即用户在输入元素中按ENTER或“x”键。<input>的类型是search,因为它是供用户搜索的。InternetExplorer,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>热门推荐
10 读书祝福语女生短句简短
11 感谢同事新婚祝福语简短
12 感谢教官文案祝福语简短
13 员工聚会蛋糕祝福语简短
14 元宵发客户祝福语简短
15 给团队信心祝福语简短
16 医美的祝福语大全简短
17 异国姻缘的祝福语简短
18 兄妹拍照祝福语简短的话