jquery - 关于 jquery.ui.spinner 的查询:事件未引发
问题描述
我目前正在使用带有 jquery 版本 'jquery-ui-1.10.4.js' 的 'ui-spinner'
有一个按钮,其可见性取决于 ui-spinner。我可以通过在 ui-spinner 上引发 onchange/keypress/keydown 事件来设置可见性,但这仅在使用微调器箭头时才有效。如果我通过 ui-spinner 中的键盘输入任何数字,则按钮可见性不会得到更新,因为在这种情况下不会引发任何事件。仅当我在 ui-spinner 文本框中输入数字后单击屏幕上的其他任何位置时才会引发该事件,但我需要在我在 ui-spinner 文本框中输入数字时引发事件。
下面是用户界面: 用户界面
解决方案
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>spinner demo</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<input id="spinner" onkeyup="ShowMessage(this.value)" />
<input type="button" id="btnHitMe" value="Hit Me !" disabled />
<label id="UpdateValue">ddd</label>
<script>
$("#spinner").spinner();
function ShowMessage(value) {
$("#btnHitMe").prop('disabled', !(value.length > 0));
console.log(value);
$("#UpdateValue").text(value.length);
}
</script>
</body>
</html>
推荐阅读
- java - 在android上验证谷歌云api
- c - 解释内存的 GDB/LLDB 十六进制转储
- spring-boot - 如何在 Nexus 存储库中使用 Spring 快照
- c++ - Termios C++ 串行读取不读取 arduino 串行
- html - 从带有图像的括号中压缩 html 签名
- amazon-web-services - 如果启用 CloudFront,s3 存储桶区域真的很重要吗?
- oop - 具有已删除移动运算符的成员的类的移动运算符
- mysql - MySQL - 基于多个列不起作用的百分比增加
- java - 将 Map 转换为 JSONObject
- screenshot - Direct3D 是否从 GDI32.dll 调用 bitBlt