简体   繁体   English

获取新添加的元素的ID DOM

[英]get newly added element's id DOM

I am adding image from php using ajax. 我正在使用ajax从php添加图像。 I want to process image after getting it on DOM. 我想在DOM上获取图像后进行处理。 I am able to load the image. 我能够加载图像。 but I cannot figure it out how to detect in jquery for newly inserted DOM element. 但是我无法弄清楚如何在jquery中检测新插入的DOM元素。

I tried with this: 我尝试了这个:

document.addEventListener("DOMNodeInserted", function(event) {
    alert($(event.target).parent()[0].tagName);
});

But, It's little bit different thing. 但是,这有点不同。

For elements loaded post DOM load, you can use bind() or on() 对于在DOM加载后加载的元素,可以使用bind()on()

http://api.jquery.com/on/ https://api.jquery.com/bind/ http://api.jquery.com/on/ https://api.jquery.com/bind/

It would be helpful if you provided more details on what you are trying to do exactly. 如果您提供有关您要确切执行的操作的更多详细信息,将很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM