我使用jquery mobile和phoneGap在android中创建应用程序。
在HTML5标准中,<input type='search' onsearch='searchHandler()'>
但是搜索事件没有被触发?
是因为我在用手机吗。
有其他方法可以使用吗?
您可以绑定到change
事件,以确保在用户完成键入后捕获搜索字符串:
$('input[type="search"]').on('change', function (event) {
//the user has changed the value and de-focused the element or submitted the search
});
下面是一个演示:http://jsfiddle.net/w9Bdg/1/
请注意,.on()
是jQuery 1.7中的新版本,如果您使用的是旧版本,则在本例中与.bind()
相同。