Javascript通用方式来了解添加的新元素 [英] Javascript Universal way to know added new element
问题描述
Javascript中的AddEventHandler用于普遍处理事件(例如onclick)(即在任何元素上)。
AddEventHandler in Javascript is for handling the events (like onclick) universally (i.e. on any element).
有没有办法在添加新元素(即输入,div,选择等)时触发事件(不知道哪种类型)页面(通过Ajax,jQuery等)?
Is there a way to fire an event (don't know which kind) when a new element (i.e input, div, select, etc.) is being added to the page (through Ajax, jQuery, etc.)?
我查看了dev mozilla上的DOM文档但找不到任何内容。可能是我没找对页。
I've looked into the DOM documentation on dev mozilla but couldn't find anything. May be I'm not looking in the right pages.
推荐答案
你有什么理由想知道吗?如果您希望将事件处理程序添加到新元素,则可以使用jQuery的实时功能。
Is there a reason you want to know? If the reason is you want to add event handlers to new elements, you could use the "Live" functionality of jQuery instead.
这篇关于Javascript通用方式来了解添加的新元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!