@Figha'nın dediği gibi, eğer bu kendi web sayfanızsa , öğeyi görünür hale getirdikten sonra çalıştırmanız gereken her şeyi çalıştırmalısınız.
Ancak, soruyu yanıtlamak amacıyla (ve bunun yaygın bir kullanım durumu olduğu Chrome veya Firefox Uzantıları yapan herkes ), Mutation Summary ve Mutation Observer , DOM değişikliklerinin olayları tetiklemesine izin verecektir.
Örneğin data-widget, DOM'a eklenen özniteliğe sahip bir öğe için bir olay tetikleme . Bu mükemmel örneği David Walsh'un blogundan ödünç alarak :
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);
Yanıtlar içerir added, removed, valueChangedve daha fazlası . valueChangeddahil olmak üzere tüm özellikleri içerir display.