本文介绍了您如何检测“搜索"的清除?HTML5 输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 HTML5 中,search 输入类型会在右侧显示一个小 X,它会清除文本框(至少在 Chrome 中,可能是其他).除了检测框何时被点击或进行某种位置点击检测(x 位置/y 位置)之外,有没有办法检测何时在 Javascript 或 jQuery 中单击此 X?

In HTML5, the search input type appears with a little X on the right that will clear the textbox (at least in Chrome, maybe others). Is there a way to detect when this X is clicked in Javascript or jQuery other than, say, detecting when the box is clicked at all or doing some sort of location click-detecting (x-position/y-position)?

推荐答案

其实就是一个搜索"每当用户搜索或用户点击x"时触发的事件.这特别有用,因为它理解增量"属性.

Actually, there is a "search" event that is fired whenever the user searches, or when the user clicks the "x". This is especially useful because it understands the "incremental" attribute.

现在,话虽如此,我不确定您是否能分辨单击x"和单击x"之间的区别.和搜索,除非您使用onclick"黑客.无论哪种方式,希望这会有所帮助.

Now, having said that, I'm not sure if you can tell the difference between clicking the "x" and searching, unless you use an "onclick" hack. Either way, hopefully this helps.

Dottoro 网络参考

这篇关于您如何检测“搜索"的清除?HTML5 输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:07