开发者

HTML5 input type="search" issue

I'm working on a Google Chrome extension, and using for a search box, the search displays results in an inline div rather than having a submit button and g开发者_JAVA百科oing off to a different page when it is clicked.

Is there any way to detect when the "X" button is pressed at the end of the search field, i need to close the inline div when it is but I don't know how to detect if its been pressed.


I believe there isn't a way to do that. But if you can listen on the search event, that occurs when the user presses the ENTER key or clicks on the "X" button.

If you want to see if you clicked on the "x" maybe this hack is good enough? Figure out if the contents is empty. (sure this will be true if you press "enter" on empty text"

search.addEventListener('search', function(e) {
  console.debug(search.value.length == 0)
}, false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜