首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Internet延迟为"onfocusout“事件分配函数

Internet延迟为"onfocusout“事件分配函数
EN

Stack Overflow用户
提问于 2014-10-23 07:37:56
回答 1查看 28关注 0票数 0

当用户离开当前输入字段时,我的HTML表单正在执行一个操作(向表单中添加一条新行,以便能够输入另一个电话号码)。

当使用IE执行时,此代码会造成很大的滞后:

代码语言:javascript
复制
    $("#createOrUpdateContactPersonPhoneNumber0").on('focusout', function() {
       addAnotherRow();
    });

function addAnotherRow() {

 $("#phoneNumberTable tr:last-child").before('<tr><td><select style="width: 100px;" id="createOrUpdateContactPersonPhoneType' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"></select></td><td><select id="createOrUpdateContactPersonPhoneCountry' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"></select></td><td><input style="height: 21px;" type="text" id="createOrUpdateContactPersonPhoneNumber' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"/></td><td><input style="height: 21px; width: 100px;" type="text" id="createOrUpdateContactPersonPhoneExtension' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"/></td><td><select id="createOrUpdateContactPersonPhonePurpose' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"></select></td><td><center><input type="radio" name="createOrUpdateContactPersonPhonePrimary" id="createOrUpdateContactPersonPhonePrimary' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"/></center></td><td></td></tr>');

};

当将函数"addAnotherRow()“的代码直接添加到.on('focusout')事件时,没有任何滞后。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-23 07:40:23

使用onBlur而不是onFocusOut。请注意,onBlur不冒泡。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26523304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档