如何将点击事件触发到通过Ajax加载但未添加的DOM中

我需要触发所有ant元素的点击,然后将生成的dom读取到dom中,并保存到变量中,如何在不附加dom的情况下从ajax调用中获取dom?

或者我如何将dom加载到一些隐藏的浏览器选项卡中,以使窗口和文档事件气泡成为可能?

let url = 'https://www.amazon.com/dp/B07VHXT1R3';
  $.get( url ).then(resp => {
    let dom = $( resp );

    //images preload 
    dom.find('#altImages li input').each(function(){
      // this would generate other elements inside the dynamic dom,// but this is stored into a variable 
      $(this).trigger('click');
    });

    let images = [];
    dom.find('li.image img').each(function(){
      // this would have to read the images generated
      // but only read one element that comes already rendered 
      images.push( $(this).data('old-hires') || this.src );
    });

[ ... ]

具体来说,我需要冒泡进入未渲染的dom,并且不绑定窗口和文档对象

有人知道如何在不使RAM崩溃的情况下做到这一点吗?

hanjinshuen 回答:如何将点击事件触发到通过Ajax加载但未添加的DOM中

我用正则表达式解决了

let images = dom.text().match(/(?<="hiRes":")([^"]+)(?=")/gi).filter( (v,i,s) => { return s.indexOf(v) === i });
本文链接:https://www.f2er.com/3133985.html

大家都在问