如何用javascript/Jquery调用iOS搜索按钮?

How to call the iOS search button with javascript/Jquery?

我有一个我用过的搜索区域

<form><input name="search"/></form>

启用并显示 iOS 移动键盘上的搜索按钮。

我现在的问题是,我如何在代码中找到这个搜索按钮,以便我可以添加一个 onclick="(callFunction)" 例如,如果我自己创建了一个按钮,我就可以这样做。非常感谢任何帮助或输入,谢谢!

我认为您正在使用 type="search",因此您可以将事件处理程序附加到 search 事件,例如:

$('input[type=search]').on('search', function () {
    // search logic
});

或:

<input type="search" name="search" onsearch="OnSearch(this)"/>

文档:

Occurs when the user presses the ENTER key or clicks the 'Erase search text' button (x) in an input:search field.

参考:http://help.dottoro.com/ljdvxmhr.php

演示:http://jsfiddle.net/rb684u8o/