简体   繁体   English

jQuery-等待元素显示在iFrame中并获取其值?

[英]jQuery - wait for an element to show up within an iFrame and grab its value?

Suppose upon an event an iframe opens. 假设一个事件打开了iframe。 (no cross site, the iframe is part of the DOM). (没有跨站点,iframe是DOM的一部分)。

So when the iframe opens it displays for example to select a file. 因此,当iframe打开时,它将显示例如选择一个文件。

在此处输入图片说明

The second state of the iFrame upon selecting the file would be displaying information about the media uploaded as well as its title. 选择文件后,iFrame的第二种状态将是显示有关上载媒体及其标题的信息。 Ex below after the file is selected. 选择文件后,请在下面单击。

在此处输入图片说明

My question is suppose I wanted to grab the value of 'Title' using JS. 我的问题是假设我想使用JS来获取“标题”的值。 How would I go on doing this? 我将如何继续这样做?

$('.addmediabutton').click(function() {

         $('body').on('DOMNodeInserted', 'iframe', function(e) {
           //How do I wait for eg. class = "title" to show up and grab its value? 

 });
});

Would I have to use a Mutation Observer above to track a given added node or element or is there an easier way. 我是否必须使用上面的Mutation Observer来跟踪给定的已添加节点或元素,或者是否有更简单的方法。

If you need any further clarification please don't hesitate to ask. 如果您需要任何进一步的说明,请随时询问。

如果在ajax调用之后到达第二种状态,则就像在ajax请求的on success部分中包含功能一样简单。

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

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