我想调用 keydown 事件以在 jquery mobile 中搜索输入类型。下面是我的 html 代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Insert title here</title>
<link rel="stylesheet" href="jquery.mobile-1.2.0.min.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#search1").keydown(function() {
alert("keydown");
$("#search1").css("background-color", "yellow");
});
$("#search1").keyup(function() {
alert("keyup");
$("#search1").css("background-color", "pink");
});
});
</script>
<script type="text/javascript" src="jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="content">
<input type="search" id="search1">
<input type="text" id="text1">
</div>
</div>
</body>
</html>
除搜索类型外,所有其他输入类型都会触发 keydown 事件。有人可以帮忙吗?
最佳答案
包含 jQuery Mobile 文件
您需要做的只是将一个 jQuery 文件包含到您的项目中。名为 jQuery.mobile.js 或非常相似(例如 jQuery.ui.js)的任何版本的文件都可以帮助您。
您可以从以下网址下载:jQuery Mobile Official | Download 我建议使用
ResolveClientUrl
同时给出路径。
关于javascript - keydown 事件不适用于 jQuery Mobile 中的输入类型搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14625409/