为什么聚焦事件被多次发射?

时间:2016-12-23 10:10:03

标签: jquery

我动态添加了一些focusout元素,然后附加了input个事件。当我运行代码时,我按下 TAB 切换到下一个alert元素,然后focusout框一个接一个地无限期出现。

当我从一个输入字段切换到另一个输入字段时,我想我应该得到一个警告框。然后,在我离开那个领域后,我应该得到另一个警报。我没有预期的行为,只要我从一个输入字段切换到另一个输入字段,我就会无限期地冻结浏览器。感谢任何帮助,了解为什么//adding few input elements dynamically $('#worker_payment_' + id).html('<input style="width: 54px;" type="text" value="' + w_payment + '">'); $('#worker_mileage_' + id).html('<input style="width: 54px;" type="text" value="' + w_mileage + '">'); $('#worker_reimburse_' + id).html('<input style="width: 54px;" type="text" value="' + w_reimburse + '">'); $('#worker_note_' + id).html('<input style="width: 54px;" type="text" value="' + w_note + '">'); $('#worker_action_' + id).html('<span style="font-size: 14px;"><g:submitButton name="Delete" class="button" onClick="handleDelete( current_selection ); return false;"/></span>'); $("#worker_name_" + id + " select").focus(); //now adding focusout events to each of these elements $("#worker_name_" + id + " select").focusout(function() { alert("focus lost"); }); $('#worker_payment_' + id + ' input').focusout(function() { alert("focus lost"); }); $('#worker_mileage_' + id+ ' input').focusout(function() { alert("focus lost"); }); $('#worker_reimburse_' + id+ ' input').focusout(function() { alert("focus lost"); }); $('#worker_note_' + id+ ' input').focusout(function() { alert("focus lost"); }); 事件被无限期解雇。谢谢!

$message = '$_POST[dostawa]';

0 个答案:

没有答案