My content changes with ajax and I want that after 200px of scrolling to trigger a click to an element.
$(window).scroll(function() {
if($(window).scrollTop() > 200){
$(".element")[0].click();
}
}
But this does not work with changing content. On first load it works. But as soon as ajax does it's stuff the event isn't firing anymore. Any ideas? I know about the on event but cannot figure it out how to use it here.
Update
The linked question does not help me:
$(staticAncestors).on(eventName, dynamicChild, function() {});
this works for clicks or other events. But I don't want to attach a click event, I want to trigger a click event. How could I do it? The change is in an ajax call beyond my control so I cannot add a callback.
Thanks