为了账号安全,请及时绑定邮箱和手机立即绑定

对焦/模糊事件未被触发

对焦/模糊事件未被触发

慕神8447489 2022-09-23 21:49:26
我试图将“焦点”事件绑定到文本框,这样每次焦点到达它时,它都应该调用一个函数。但是,它不会触发焦点事件。当我将光标放入文本框中时,没有任何反应。每当单击按钮时,都会触发绑定在“单击”事件上的其他事件。下面是代码片段: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();});}我尝试过使用“模糊”和“对焦”,但它不起作用。$('#textBoxId').bind('blur', function(event) {      console.log("IN blur call"); });为什么文本框未附加到焦点事件?
查看完整描述

1 回答

?
月关宝盒

TA贡献1772条经验 获得超5个赞

$('body').on('focus', '#textBoxId', function() {

  //code

  console.log("IN focus call");

});

$('body').on('blur', '#textBoxId', function() {

  //code

  console.log("IN blur call");

});

这将工作


查看完整回答
反对 回复 2022-09-23
  • 1 回答
  • 0 关注
  • 57 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信