Jquery 奇怪的输入框错误PC safari
在我的HTML5游戏中有一个输入框。我想在手机和PC上都使用它,所以我同时包括了手机jquery和PC jqueryJquery 奇怪的输入框错误PC safari,jquery,html,inputbox,Jquery,Html,Inputbox,在我的HTML5游戏中有一个输入框。我想在手机和PC上都使用它,所以我同时包括了手机jquery和PC jquery <input id="searcher" data-role="none" type="search" placeholder="Search Friends" style="position:absolute; background-color:white; display:block;"> 这些都是我使用的事件侦听器。代码中
<input id="searcher" data-role="none" type="search" placeholder="Search Friends"
style="position:absolute; background-color:white; display:block;">
这些都是我使用的事件侦听器。代码中有一些冗余<不应手动添加和删除代码>占位符
$("#searcher").on("input", function () {
var text = $("#searcher").val();
// If the text is empty, hide the keyboard and blur the search text box.
if (text === "") return;
// Do a search in middle layer.
fuseDoSearch(text);
// Call this function to refresh the UI.
refreshUI();
}).on(mobile ? "touchstart" : "mousedown", function() {
// There is a bug in mobile devices that you have to hold the input
// box for a while to get focus of the input box. So use this to force
// the input box to get focus when clicked on.
$("#searcher").focus();
});
这也可以解决您的问题。
返回将阻止搜索继续使用空字符串。我很确定这就是破坏一切的原因。您的搜索功能是如何工作的?如果它挂在一个空字符串上,那就是你的问题。你有什么代码?输入字段是否有EventListeners?控制台中有错误吗?@minitech我已经编辑了问题描述。谢谢@Mathias我已经在编辑的问题描述中回答了你的问题。控制台中没有错误。谢谢
$("#searcher").on("input", function () {
var text = $("#searcher").val();
// If the text is empty, hide the keyboard and blur the search text box.
if (text === "") return;
// Do a search in middle layer.
fuseDoSearch(text);
// Call this function to refresh the UI.
refreshUI();
}).on(mobile ? "touchstart" : "mousedown", function() {
// There is a bug in mobile devices that you have to hold the input
// box for a while to get focus of the input box. So use this to force
// the input box to get focus when clicked on.
$("#searcher").focus();
});