Como dice @figha, si esta es su propia página web , debe ejecutar lo que necesite ejecutar después de hacer visible el elemento.
Sin embargo, con el fin de responder a la pregunta (y para cualquiera que haga extensiones de Chrome o Firefox , donde este es un caso de uso común), Mutation Summary y Mutation Observer permitirán que los cambios DOM activen eventos.
Por ejemplo, activar un evento para un elemento con un data-widgetatributo que se agrega al DOM. Tomando prestado este excelente ejemplo del blog de David Walsh :
var observer = new MutationObserver(function(mutations) {
// For the sake of...observation...let's output the mutation to console to see how this all works
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});
// Notify me of everything!
var observerConfig = {
attributes: true,
childList: true,
characterData: true
};
// Node, config
// In this case we'll listen to all changes to body and child nodes
var targetNode = document.body;
observer.observe(targetNode, observerConfig);
Las respuestas incluyen added, removed, valueChangedy mucho más . valueChangedincluye todos los atributos, incluidos displayetc.