Is it possible to have a Chrome extension listen for the appearance of a yet-to-be-created element?
Say the user clicks a button and the click event creates an element <div id='myDiv'>My Div</div>
and adds it to the page/DOM. Is it possible to set a listener that will automatically fire an event when that element appears?
Or do I have to resort to polling the page and checking for this element every X amount of milliseconds?
jQuery and other libraries are not an option for me btw.
You can use arrive.js, it wraps the Mutation Observers api. Usage:
document.arrive(".test-elem", function() {
// 'this' refers to the newly created element
var newElem = this;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With