jquery onblur not firing
jquery onblur not firing
我试图得到一个onblur/onfocus组合工作的一对文本框,我通过类在jquery中选择。我在调试中没有得到任何错误,但模糊函数似乎从未被调用。当调试我的断点在模糊函数没有击中。
$(document).ready(function () {
var row = $(this).closest('tr');
$('.editClass').click(function () {
var editBoxes = $(row).find('.editClass');
var focus = 0;
$(editBoxes).focus(function () { focus++ });
$(editBoxes).blur(function () {
focus--;
setTimeout(function () {
if (!focus) {
alert('LOST FOCUS'); // both lost focus
}
}, 50);
});
});
});
很确定这里的问题是editbox是动态添加到页面的。这在我的问题中并不明显。因为它们是动态添加的,所以我需要使用
$(document).on('blur', '.editBoxes', function (){
...
}
你的代码示例的最后两行应该是这样的
});
});
这是关闭ready和click函数调用所需的。
另一个可能的问题是,您将焦点和模糊侦听器包装在单击处理程序中。你为什么要这么做?
相关文章:
- WebSocket onmessage not firing
- Backbone model.change() not firing
- codemirror onKeyEvent not firing
- Dojo onBeforeTransitionIn not firing
- CSS TransitionEnd not firing
- RegisterClientScriptBlock - not firing
- GWT History.back() is not firing onValueChangeHandler
- Signalr connection.start.done not firing
- Javascript XMLHttpRequest onreadystatechanged not firing?
- jstree select_node.jstree not firing
- Jquery not firing
- jQuery.on("drop") not firing
- Javascript window.onload not firing
- MVC 5 javascript not firing
- Javascript FileReader onload not firing
- setTimeout not firing jQuery
- setInterval() not firing
- $.getJSON not firing console.log
- Sails.js IO.socket not firing
- react componentDidMount not firing