[英]Focus/blur event not getting triggered
I am trying to bind a "focus" event to a textbox, such that everytime the focus comes to it, it should call a function.我正在尝试将“焦点”事件绑定到文本框,这样每次焦点来到它时,它都应该调用 function。 However, it is not triggering the focus event.但是,它不会触发焦点事件。 When I bring my cursor inside the textbox, nothing happens.当我将 cursor 带入文本框时,什么也没有发生。 Other event which is bind on "click" event is triggered whenever the button is clicked.每当单击按钮时,都会触发与“单击”事件绑定的其他事件。
Below is the code snippet:下面是代码片段:
P.when('A', 'ready').register('dom-updater', function(A) {
var $ = A.$;
var render = function () {
if (state.widgetType === "maker") {
$('#saveData').bind('click', function(event) {
saveInfoData();
});
$('#verifyBtn').bind('click', function(event) {
validateData();
});
//This line does not work
$( "#textBoxId" ).focus(function() {
console.log( "Handler for .focus() called." );
});
} else {
//Do something else
}
};
A.on.ready(function() {
render();
});
}
I have tried using 'blur' and also 'focus', but it is not working.我尝试过使用“模糊”和“焦点”,但它不起作用。
$('#textBoxId').bind('blur', function(event) {
console.log("IN blur call");
});
Why is the textbox not getting attached to the focus event?为什么文本框没有附加到焦点事件?
$('body').on('focus', '#textBoxId', function() {
//code
console.log("IN focus call");
});
$('body').on('blur', '#textBoxId', function() {
//code
console.log("IN blur call");
});
this will work这会起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.