版权声明:本文为博主原创文章,如有错误劳烦指正。转载请声明出处,便于读取最新内容。——Bestcxx https://blog.csdn.net/bestcxx/article/details/83583348
JQuery 实时监听文本框变化
使用 input propertychange
html 的文本框
<input thpe="text" id="theId" name="theId" />
js 代码
$(function(){
$('#theId').on('input propertychange', function() {
//这里加你需要的逻辑
});
});
JS 监听长按事件
$(function(){
$(function(){
$("#被监听的元素id").longPress(function(){
alert(1);
});
});
方法
$.fn.longPress = function(fn) {
var timeout = undefined;
var $this = this;
for(var i = 0;i<$this.length;i++){
$this[i].addEventListener('touchstart', function(event) {
timeout = setTimeout(fn, 800);
}, false);
$this[i].addEventListener('touchend', function(event) {
clearTimeout(timeout);
}, false);
}
}